摘要: 题目: 终端输入一个文件名,判断是否是设备文件。 答案: #!/bin/bash echo -e "please input a filename to judge it is or not a device file.\n\n" read -p "Input a filename: " filen 阅读全文
posted @ 2020-01-05 13:57 王清河 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 题目: root用户今天登陆了多长时间 答案: #!/bin/bash cat /proc/uptime | awk -F . '{run_days=$1/86400; run_hour=($1%86400)/3600;run_minute=($1%3600)/60;run_second=$1%60 阅读全文
posted @ 2020-01-05 13:42 王清河 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目: 编写个shell脚本将当前目录下大于10K的文件转移到/tmp目录下。 答案: #!/bin/bash for FileName in `ls -l | awk '$5>10240 {print $9}'`; do mv $FileName /tmp done ls -al /tmp 阅读全文
posted @ 2020-01-05 13:38 王清河 阅读(142) 评论(0) 推荐(0) 编辑