正在加载图片...
imx操作系统》实验指导/实验六:Sl编程基础8 ②统计当前目录下的文件个数及目录个数 Is-I* grep"A-"I ③编写She程序,备份 apache的所有日志,并将文件扩展名修改为bak。程序文件名 为: FileBankup vi /home/student/File Bankup sh #!/bin/bash Dir/var/log/apache2/ for file in SDi base=s(file%. *1 mv Sfile S(base). bak done (3)通过正则表达式实现信息定制化验证 编写 Shell程序,对用户输入的手机号码验证其合法性。程序文件名为: CheckPhone 参考程序: vi/home/student/CheckPhone sh #!/bin/bash read-p"Please imput your telephone number: numbers a=echo Sno we-c then echo Sa grep"l">/dev/null if[S?-eq0] if I Numbers=+(0-9DI1 then echo"Your telephone numbers are Numbers" else out IS wrol echo"Your input is wrong echo"Your input is wrong 要求: (1)编写She程序,列出/home/ student文件夹下的所有扩展名为sh的文件名 (2)编写She程序,读取用户输入的身份证号和出生年月,并验证其结构合法性和出生日 期信息的一致性 请按照上述(1)(2)2个要求,进行具体实验,并将She脚本,实验结果填写到实验报告 九、实验分析 管理科学与工程学科/共10页第8页《Linux 操作系统》实验指导 / 实验六:Shell 编程基础 管理科学与工程学科 / 共 10 页,第 8 页 ②统计当前目录下的文件个数及目录个数。 ls -l * | grep "^-" | wc -l ls -l * | grep "^d" | wc -l ③编写 Shell 程序,备份 apache 的所有日志,并将文件扩展名修改为 bak。程序文件名 为:FileBankup.sh。 vi /home/student/FileBankup.sh #!/bin/bash Dir=/var/log/apache2/ for file in $Dir do base=${file%.*} mv $file ${base}.bak done (3)通过正则表达式实现信息定制化验证 编写 Shell 程序,对用户输入的手机号码验证其合法性。程序文件名为:CheckPhone。 参考程序: vi /home/student/CheckPhone.sh #!/bin/bash read -p "Please imput your telephone number:" numbers a=`echo $no | wc -c` if [ $a -eq 12 ] then echo $a | grep "^1" > /dev/null if [ $? -eq 0 ] then if [[ $numbers == +([0-9]) ]] then echo "Your telephone numbers are $numbers" else echo "Your input is wrong" fi else echo "Your input is wrong" fi else echo "Your input is wrong" fi 要求: (1)编写 Shell 程序,列出/home/student 文件夹下的所有扩展名为 sh 的文件名; (2)编写 Shell 程序,读取用户输入的身份证号和出生年月,并验证其结构合法性和出生日 期信息的一致性。 请按照上述(1)(2)2 个要求,进行具体实验,并将 Shell 脚本,实验结果填写到实验报告 册中。 九、实验分析
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有