```shell # 01_03_05_07_09 seq -w -s_ 1 2 10 # 10 8 6 4 2 echo {10..1..2} # ABCDEFGHIJKLMNOPQRSTUVWXYZ echo {A..Z} |tr -d " " # 找code文件夹下 以.go结尾的文件 (-type d是文件夹) find ./code -type f -name "*.go" -print # 找到结果前后各加一个@ find ./code -exec echo @{}@ ";" # 将过滤出的文件ls -l一下 换而言之(换成rm就都删除了) find ./code -type f -name "*.rs" -exec ls -l {} ";" # shell 中的while loop,一直打印candide yes candide # 别像上条命令那么多 3条足矣 yes candide |head -n3 # 匹配排除空行 grep -v '^$' node.go # 匹配所有包含left和right的行 grep 'left\|right' node.go # 列出/etc/shells合法shell cut -d: -f7 /etc/passwd |sort -u |grep -f /etc/shells -F # 查看第6-8行日志 head -n 8 error.log |tail -n3 # cat反过来输出 tac 1.txt # 合并两列 paste 1.txt 2.txt # 以逗号分割行合并 paste -d, -s 1.txt 2.txt # 比较两个文件展示两个有差异的行 diff 1.txt 2.txt |grep '^[<>]' |cut -c3- # 替换结果 echo $PATH | tr : "\n" # 小写转大写 echo "candide" |tr a-z A-Z # 删掉输出中的空行 输出hellocandide echo hello candide |tr -d " " # rev反转命令,与tac不同的是,tac是行反转,这个是行字符 输出edidnac olleh echo hello candide |rev # 获取文件内容每行最后一个单词 rev 3.txt |cut -d " " -f1| rev # mock 顺序名的jpg文件 touch {1..1000}.jpg # 比较筛选缺失的顺序文件 diff <(ls *.jpg |sort -n) <(seq 1 1000 | sed 's/$/.jpg/')|grep '>' |cut -c3- # 列出当前路径下所有文件内容 ls -F |grep -v / | xargs cat # 查找当前路径下所有指定后缀的文件名 find . -type f -name \*.txt -print # ls竖着打印换成横着打印 ls |tr '\n' '\0'|xargs -0 # 把每个文件夹和文件加内容 ls |xargs -I XYZ echo XYZ is my file name # rm *.txt 如果超过1400万个字符就会报错 # bash: /bin/rm: Argument list too long ls |grep '\.txt$' | xargs rm # 安全写法 find . maxdepth 1 -name \*.txt -type f -print0 |xargs -0 rm # 将家目录文件夹加入环境变量 # 打印家目录文件夹并去掉末尾/,(用@代替/) echo "CDPATH=$HOME" $(cd && ls -d */ | sed -e 's@^@$HOME/@g' -e 's@/$@@') |tr ' ' ':' # 打印$3>=1000的用户欢迎来到北京 cat /etc/passwd |awk -F ':' '$3>=1000 {print $1}' |xargs -I@ echo "Hello @, Welcome to Beijing" ```