linux上机练习题shell程序设计基础.docxVIP

  • 25
  • 0
  • 约2.28千字
  • 约 4页
  • 2020-01-15 发布于江苏
  • 举报
上机实习题: 1. 用 Shell 编程,判断一文件是不是字符设备文件,如果是将其拷贝到 /dev 目录下。 a #!/bin/bash directory=/dev for file in /bin/a2p do if [ -f $file ] then cp $file $directory/$file.bak Fi done 编写一个 shell 脚本,完成功能: 1 )显示文字“Waiting for a while,. ” 2)长格式显示当前目录下面的文件和目录,并输出重 定向到 /home/file.txt 文件 3 )定义一个变量,名为 s ,初始值“ Hello ” 4 ) 使该变量输出重定向到 /home/string.txt 文件 m #!/bin/bash echo waiting for a while ? ls -l./home/file.txt s=hello echo $s /home/string.txt 编写一个 shell 脚本,它把第二个位置参数及其以后的 各个参数指定的文件复制到第一个位置参数指定的目录 中。 b #!/bin/bash dir=$1 shift while [$1] do file=$1 cp $1 $dir shift done ls $dir 编写一个 shell 脚本,利用 for 循环将当前目录下

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档