linux demo

1.1)if case test the results

#!bin/bash
read -p “请输入你的成绩:” num
if [ $num -ge 0 ] && [ $num -le 100 ];then

if [ $num -ge 80 ] && [ $num -le 100 ];then
echo “成绩优秀”
elif [ $num -ge 60 ] && [ $num -le 79 ];then
echo “成绩合格”
else
echo “成绩不合格”
fi

else
echo “请输入正确的成绩”
fi

1.2)remove files or directory by command rm; how to append/add content on the files

[root@iZ2vc5lqzt23aweti4j777Z ~]# ll
total 349224
drwxr-xr-x 2 root root 4096 Apr 27 18:35 April27th2024
drwxr-xr-x 2 root root 4096 Apr 28 18:21 April28th2024
drwxr-xr-x 3 root root 4096 Apr 30 12:55 April29th2024
-rw-r–r-- 1 root root 1 Apr 29 17:36 ‘^C’
-rw------- 1 root root 241286144 Apr 25 11:46 nginx1.tar
-rw------- 1 root root 116301312 Apr 25 12:59 redis.tar
[root@iZ2vc5lqzt23aweti4j777Z ~]# mkdir May6th2024
[root@iZ2vc5lqzt23aweti4j777Z ~]# mkdir May6th2024_a
[root@iZ2vc5lqzt23aweti4j777Z ~]# cd May6th2024
[root@iZ2vc5lqzt23aweti4j777Z May6th2024]# echo “Hello world~” > a.txt
[root@iZ2vc5lqzt23aweti4j777Z May6th2024]# ls
a.txt
[root@iZ2vc5lqzt23aweti4j777Z May6th2024]# cat a.txt
Hello world~
[root@iZ2vc5lqzt23aweti4j777Z May6th2024]# echo “Another line~” >> a.txt
[root@iZ2vc5lqzt23aweti4j777Z May6th2024]# cat a.txt
Hello world~
Another line~
[root@iZ2vc5lqzt23aweti4j777Z May6th2024]# cd …
[root@iZ2vc5lqzt23aweti4j777Z ~]# rmdir May6th2024
rmdir: failed to remove ‘May6th2024’: Directory not empty
[root@iZ2vc5lqzt23aweti4j777Z ~]# rmdir -R May6th2024
rmdir: invalid option – ‘R’
Try ‘rmdir --help’ for more information.
[root@iZ2vc5lqzt23aweti4j777Z ~]# rmdir -r May6th2024
rmdir: invalid option – ‘r’
Try ‘rmdir --help’ for more information.
[root@iZ2vc5lqzt23aweti4j777Z ~]# rmdir -f May6th2024
rmdir: invalid option – ‘f’
Try ‘rmdir --help’ for more information.
[root@iZ2vc5lqzt23aweti4j777Z ~]# rmdir -fr May6th2024
rmdir: invalid option – ‘f’
Try ‘rmdir --help’ for more information.
[root@iZ2vc5lqzt23aweti4j777Z ~]# rm -r May6th2024
rm: descend into directory ‘May6th2024’? ^C
[root@iZ2vc5lqzt23aweti4j777Z ~]# rm -fr May6th2024
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll
total 349228
drwxr-xr-x 2 root root 4096 Apr 27 18:35 April27th2024
drwxr-xr-x 2 root root 4096 Apr 28 18:21 April28th2024
drwxr-xr-x 3 root root 4096 Apr 30 12:55 April29th2024
-rw-r–r-- 1 root root 1 Apr 29 17:36 ‘^C’
drwxr-xr-x 2 root root 4096 May 6 19:57 May6th2024_a
-rw------- 1 root root 241286144 Apr 25 11:46 nginx1.tar
-rw------- 1 root root 116301312 Apr 25 12:59 redis.tar
[root@iZ2vc5lqzt23aweti4j777Z ~]# rmdir May6th2024_a/
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll
total 349224
drwxr-xr-x 2 root root 4096 Apr 27 18:35 April27th2024
drwxr-xr-x 2 root root 4096 Apr 28 18:21 April28th2024
drwxr-xr-x 3 root root 4096 Apr 30 12:55 April29th2024
-rw-r–r-- 1 root root 1 Apr 29 17:36 ‘^C’
-rw------- 1 root root 241286144 Apr 25 11:46 nginx1.tar
-rw------- 1 root root 116301312 Apr 25 12:59 redis.tar
[root@iZ2vc5lqzt23aweti4j777Z ~]# mkdir May6th2024_a
[root@iZ2vc5lqzt23aweti4j777Z ~]# rm May6th2024_a
rm: cannot remove ‘May6th2024_a’: Is a directory
[root@iZ2vc5lqzt23aweti4j777Z ~]# rm -r May6th2024_a
rm: remove directory ‘May6th2024_a’? ^C
[root@iZ2vc5lqzt23aweti4j777Z ~]# rm -fr May6th2024_a
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll
total 349224
drwxr-xr-x 2 root root 4096 Apr 27 18:35 April27th2024
drwxr-xr-x 2 root root 4096 Apr 28 18:21 April28th2024
drwxr-xr-x 3 root root 4096 Apr 30 12:55 April29th2024
-rw-r–r-- 1 root root 1 Apr 29 17:36 ‘^C’
-rw------- 1 root root 241286144 Apr 25 11:46 nginx1.tar
-rw------- 1 root root 116301312 Apr 25 12:59 redis.tar
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值