Saturday, August 31, 2019

Linux Files and Directories 簡單操作

返回之前身處的 directory (go back to the last directory):
cd -

暫停進程,然後放它到背景,再執行 (Pause Process + Put it back to Background / Foreground):
Ctrl+Z / fg / bg

在 Ubuntu 中,數該資料夾內有多少個檔案 (Counting number of files by counting new line feed):
find DIR_NAME -type f | wc -l

在任何 Linux 中數檔案 (Counting number of files in other platform by counting new line feed character):
ls -1 | wc -l

一次清除/復原輸入中的指令 (Clear typing command and restore command):

Ctrl+U  #clear typing command
Ctrl+P  #restore recently cleared command (not present in busybox) 

快速尋找檔案名 (find file recursively quickly):
find -name <filename> 

列出系統中頭 30 個最大的檔案 (Sort the first 30 largest files):
du -ha | sort -rh | head -30

在指定資料夾中尋找 Pattern (search occurrence of a string in a folder(and its content)):
grep -ir <pattern> [location]

尋找多個 keywords (search with multiple keywords):

grep -e "regex1" -e "regex2" 

No comments:

Post a Comment