Linux简单Shell脚本编程

echo"**cmdmenu**"echo"1----日期"echo"2----ls"echo"3----谁"echo"4----pwd"echo"选择::"readnumberif[1==$number];tendate;if[2==#number];thenls;if[3==$number];thenwho;if[4==#number];thenpwd;elseecho"youarewrong"fi我没有调试这个程序,我只是给你一个想法,你可以按照我的框架,自己调试一下,希望对你有帮助,谢谢!

linuxshell编程

(1)编写shell程序恢复文件:#!/bin/shDIRNAME=`ls/root|grepbak`if[-z"$DIRNAME"];thenmkdir/root/bakcd/root/bakfiYY=`date+%y`MM=`日期+%m`DD=`日期+%d`BACKETC=$YY$MM$DD_etc.tar.gztarzcvf$BACKETC/etcecho"文件备份完成!"(2)编写任务定时器:echo"001**/bin/sh/usr/bin/fileback">;/root/etcbakcroncrontab/root/etcbakcron或者使用crontab-e命令添加定时任务:01***/bin/sh/usr/bin/fileback