1、 用 sed 修改 test.txt 的 23 行 test 为 tset; sed –i ‘23s/test/tset/g’ test.txt2、 查看/web.log 第 25 行第三列的内容。 sed –n ‘25p’ /web.log | cut –d “ ” –f3 head –n25 /web.log | tail –n1 | cut –d “ ” –f3 awk –F “ ” ‘NR==23{print $3}’ /web.log3、 删除每个临时文献的最初三行。 sed –i ‘1,3d’ /tmp/*.tmp4、 脚本编程:求 100 内的质数。 #!/bin/bash i=1 while [ $i -le 100 ];do ret=1 for (( j=2;j<$i;j++ ));do if [ $(($i%$j)) -eq 0 ];thenret=0break fi done if [ $ret -eq 1 ];then echo -n "$i " fi i=$(( i+1 )) done5、 晚上 11 点到早上 8 点之间每两个小时查看一次系统日期与时间,写出详细配置命令 echo 1 23,1-8/2 * * * root /tmp/walldate.sh >> /etc/crontab6、 编写个 shell 脚本将目前目录下不小于 10K 的文献转移到/tmp 目录下 #!/bin/bash fileinfo=($(du ./*)) length=${#fileinfo[@]} for((i=0;i<$length;i=$(( i+2 ))));do if [ ${fileinfo[$i]} -le 10 ];then mv ${fileinfo[$(( i+1 ))]} /tmp fi done7、 怎样将当地 80 端口的祈求转发到 8080 端口,目前主机 IP 为 /sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 192.168.2.1:8080 /sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 80808、 在 11 月份内,每天的早上 6 点到 12 点中,每隔 2 小时执行一次/usr/bin/httpd.sh 怎么实现 echo "1 6-12/2 * * * root /usr/bin/httpd.sh >> /etc/crontab"9、 在 shell 环境怎样杀死一种进程? ps aux | grep | cut -f? 得到 pid cat /proc/pid kill pid10、在 shell 环境怎样查找一种文献? find / -name abc.txt11、在 shell 里怎样新建一种文献? touch ~/newfile.txt12、linux 下面的 sed 和 awk 的编写1) 怎样显示文本 file.txt 中第二大列不小于 56789 的行? awk -F "," '{if($2>56789){print $0}}' file.txt2) 显示 file.txt 的 1,3,5,7,10,15 行? sed -n "1p;3p;5p;7p;10p;15p" file.txt awk 'NR==1||NR==3||NR==5||…||NR=15{print $0}' file.txt3) 将...