meikkiie 发表于 2018-8-23 07:53:17

25道shell面试题

  1、用sed修改test.txt的23行test为tset;
  sed–i ‘23s/test/tset/g’ test.txt
  2、查看/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.log
  3、删除每个临时文件的最初三行。
  sed–i ‘1,3d’ /tmp/*.tmp
  4、脚本编程:求100内的质数。
  #!/bin/bash
  i=1
  while[ $i -le 100 ];do
  ret=1
  for(( j=2;j> /etc/crontab
  6、编写个shell脚本将当前目录下大于10K的文件转移到/tmp目录下
  #!/bin/bash
  fileinfo=($(du./*))
  length=${#fileinfo[@]}
  for((i=0;i
页: [1]
查看完整版本: 25道shell面试题