Linux的shell编程作业?

Linux的shell编程作业?,第1张

1. test.shell脚本内容如下:

#!/bin/bash

name="Mike" # 定义name变量并赋值

echo ${name} # 输出name变量的值

date # 显示当前系统的日期和时间

cd /tmp # 切换到/tmp目录

pwd # 输出当前绝对路径

运行结果如下:

2. 运行脚本:sh test.shell  或者 chmod +x test.shell &&./test.shell # 变为可执行文件

如果帮到你,望采纳~

1、

#!/bin/bash

dir=$1

cd $ dir

shift

for f in $@

do

cat $f

done

2、

#!/bin/bash

for file in `ls -1 /root/a | grep ".*.c"`

{

mv /root/a/$file /root/b

}

ls -lS /root/b

3.

@City = qw/Sydney Osaka Beijing........./

for($i=0,i<10i++)

{

echo "$city[i]"

}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/7643977.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-08
下一篇2023-04-08

发表评论

登录后才能评论

评论列表(0条)

    保存