cut -d ':' -f 1 /etc/passwd
以冒号为分割符打印第一列值


sort -t ':' -k 3 /etc/passwd
sort是排序asc码排序,冒号为分隔符对第三段进行排序;
sort -t ':' -k 3 -n /etc/passwd
-n:按数字排
sort -t ':' -k 3 -n /etc/passwd | cut -d ':' -f 3 /etc/passwd
cut -d ':' -f 3 /etc/passwd | sort -n [nr:倒序排列]
cut -d ':' -f 3 /etc/passwd | sort -n |uniq -c [uniq -c:去重并显示次数]
cat 1.txt
dsdhk dsdsdsldj
dsdksdsdde@#jifdjl;fdffn
fdfndsfunef fdsfk fdmfkdsm 1234342
sdsamfmkf
cat -A 1.txt 可以看到回车符$
wc 1.txt
4 8 86 1.txt [四行、8个单词(空格分隔)、86个字符]
#!/bin/bash
line=`wc -l 1.txt|cut -d ' ' -f 1`
if [ $line -lt "8" ];then
echo "no"
fi
line=`wc -l 1.txt|cut -d ' ' -f 1` 4行
如果4<8,打印no
1.if后要有空格!
2.[]开头和结尾要有空格!
cat 1.txt | tee 1.log
cat 1.txt >1.log
区别是tee会在屏幕上打出文本内容
tr:替换
ls |tr 'a-z' 'A-Z'
wc -l 1.txt
split -l 1 1.txt
split:切割 每行分成一个文件
split -l 1 1.txt shen
-rw-r--r-- 1 root root 14 Apr 6 13:28 shenaa
-rw-r--r-- 1 root root 25 Apr 6 13:28 shenab
-rw-r--r-- 1 root root 35 Apr 6 13:28 shenac
-rw-r--r-- 1 root root 10 Apr 6 13:28 shenad
ls shen*|xargs -i mv {} {}.txt 全部加上.txt
-rw-r--r-- 1 root root 14 Apr 6 13:28 shenaa.txt
-rw-r--r-- 1 root root 25 Apr 6 13:28 shenab.txt
-rw-r--r-- 1 root root 35 Apr 6 13:28 shenac.txt
-rw-r--r-- 1 root root 10 Apr 6 13:28 shenad.txt
浙公网安备 33010602011771号