Linux 文字處理核心工具箱,單行解決 90% 需求,複雜任務改用 Python。

find . \( -name "*.txt" -o -name "*.pdf" \) -print、find . -regex ".*\(\.txt\|\.pdf\)$"、find . ! -name "*.txt"、find . -maxdepth 1 -type f、find . -type f -size +2k、find . -type f -perm 644、find . -user weber、find . -name "*.swp" -deletegrep -r "pattern" .、grep -v "exclude"、grep -c "pattern" file、grep -n "pattern" file、grep -A2 -B2 "pattern" filefind . -name "*.log" -print0 | xargs -0 rmsort file | uniq -c | sort -nr 統計行頻率。tr 'a-z' 'A-Z' 大小寫轉換、tr -d '\r' 移除 DOS 換行。cut -d: -f1 /etc/passwd 取第一欄。paste file1 file2 合併欄位。wc -l file 計行數。sed 's/old/new/g' file、sed -n '10,20p' file 顯示 10-20 行。awk -F: '{print $1,$3}' /etc/passwd、awk '$3>1000' /etc/passwd 篩選 UID>1000。熟練組合管道(|)即可完成強大資料轉換。
上一頁1234567下一頁共7頁