Skip to main content

Shell Tool

shell

  • ncdu => 查看檔案大小工具(取代du)
  • jg => 處理json字串好工具
  • tail => offset by \n
  • head => limit by \n
  • less => print data with big file
  • nl => show line numbe
  • wc(算數/算行)
  • man(manual)
  • pipe(|)
    • 將前一個的standand out 放到下一個的standard in
  • > >>
    • > 完全覆蓋
    • >> 累計加上
for i in a b c; do echo $i; done

# generate serial output(number or string)
seq 10

shell calculate

# $(()) 兩個括號就可以算數
echo $((10+20))

ls -al | grep 'TEST/[^/]\+/$' | awk '{print $4}'

awk 'print $4' => 取得前一個std out 第四格資料

read strings with array

cat test.txt | while IFS= read -r varline; do echo "test => $varline" ;done

shell note

  • fd => Simple, fast and user-friendly alternative to find
  • rg => rip grep
  • tldr => alternate man
  • modern bash => easier to use bash command recommend

查Port

lsof -PiTCP -sTCP:LISTEN