file.sh 495 B

12345678910111213141516171819202122232425
  1. # (1)
  2. tail -n +23 file.txt | head -n 1
  3. sed -n '23p' file.txt
  4. awk 'NR==23' file.txt
  5. # (2)
  6. awk '{for(i=1;i<=NF;i++) num[$i]++;} END{ for(k in num) print k" "num[k]}' file.txt | sort -rnk 2
  7. # (3)
  8. #!/bin/bash
  9. function run_daemon() {
  10. while true
  11. do
  12. for i in {20001..20003}
  13. do
  14. local num=$(lsof -i:$i | grep "^start " | wc -l)
  15. if [ $num -eq 0 ];then
  16. nohup ./start $i > start_$i.out 2>&1 &
  17. fi
  18. done
  19. sleep 1
  20. done
  21. }
  22. nohup run_daemon > run_daemon.out 2>&1 &