cut

将文件分成几个部分(列)
将标准输出写入每个输入文件的每一行的选定部分,如果没有给出文件,则写入标准输入,或者将文件名写入“ - ”

语法

 cut [OPTION]... [FILE]...

在下面的选项中,BYTE-LIST,CHARACTER-LIST和FIELD-LIST是一个或多个数字或范围(两个数字用短划线分隔)

字节,字符和字段从1开始编号,并以逗号分隔。
可以给出不完整的范围:-M表示1-M; N-表示N到行末尾或最后一个字段。

选项

-b BYTE-LIST
--bytes=BYTE-LIST
    仅打印BYTE-LIST中列出的位置中的字节。 选项卡和退格键被视为任何其他字符; 他们占用1个字节。

-c CHARACTER-LIST
--characters=CHARACTER-LIST
    仅打印CHARACTER-LIST中列出的位置中的字符。 
    现在与`-b'相同,但国际化将改变这一点。 
    选项卡和退格键被视为任何其他字符; 他们占用了1个char

-f FIELD-LIST
--fields=FIELD-LIST
    仅打印FIELD-LIST中列出的字段。 默认情况下,字段由TAB字符分隔。

-d INPUT_DELIM_BYTE
--delimiter=INPUT_DELIM_BYTE
     对于`-f',字段在输入中由INPUT_DELIM_BYTE中的第一个字符分隔(默认为TAB)。
-n
    不拆分多字节字符

-s
--only-delimited
    对于`-f',不打印不包含字段分隔符的行。

--output-delimiter=OUTPUT_DELIM_STRING
    对于`-f',输出字段由OUTPUT_DELIM_STRING分隔。
    默认情况下使用输入分隔符。

实例

以分号(;)分隔文件中解析出第2列:

$ cat myfile.txt | cut -d ; -f 2 > output.txt

cut 命令实例:

linux命令:cut -d: -f1 /etc/passwd | sort sort | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | sortrootopen.com
linux命令:cut -d: -f1 /etc/passwd | sort sort | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | sortrootopen.com
2018-02-07 16:08:48

linux命令:cut -d: -f1 /etc/passwd | grep -vE "#" | xargs -i{} crontab -u {} -l -l {} -u crontab -i{} xargs | "#" -vE grep | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | grep -vE "#" | xargs -i{} crontab -u {} -lrootopen.com
linux命令:cut -d: -f1 /etc/passwd | grep -vE "#" | xargs -i{} crontab -u {} -l -l {} -u crontab -i{} xargs | "#" -vE grep | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | grep -vE "#" | xargs -i{} crontab -u {} -lrootopen.com
2018-05-10 06:31:48

linux命令:cut -f N- file.dat file.dat N- -f cut cut -f N- file.datrootopen.com
linux命令:cut -f N- file.dat file.dat N- -f cut cut -f N- file.datrootopen.com
2018-04-22 13:02:48

linux命令:cut -f 2- -d " " " " -d 2- -f cut cut -f 2- -d " "rootopen.com
linux命令:cut -f 2- -d " " " " -d 2- -f cut cut -f 2- -d " "rootopen.com
2018-05-02 05:23:48

linux命令:cut -f2 file.txt | cut -d " " -f1 -f1 " " -d cut | file.txt -f2 cut cut -f2 file.txt | cut -d " " -f1rootopen.com
linux命令:cut -f2 file.txt | cut -d " " -f1 -f1 " " -d cut | file.txt -f2 cut cut -f2 file.txt | cut -d " " -f1rootopen.com
2018-04-11 21:14:48

linux命令:cut -d\ -f 1 ~/.bash_history | sort | uniq -c | sort -rn | head -n 10 | sed 's/.*/ &/g' &/g' 's/.*/ sed | 10 -n head | -rn sort | -c uniq | sort | ~/.bash_history 1 -f -d\ cut cut -d\ -f 1 ~/.bash_history | sort | uniq -c | sort -rn | head -n 10 | sed 's/.*/ &/g'rootopen.com
linux命令:cut -d\ -f 1 ~/.bash_history | sort | uniq -c | sort -rn | head -n 10 | sed 's/.*/ &/g' &/g' 's/.*/ sed | 10 -n head | -rn sort | -c uniq | sort | ~/.bash_history 1 -f -d\ cut cut -d\ -f 1 ~/.bash_history | sort | uniq -c | sort -rn | head -n 10 | sed 's/.*/ &/g'rootopen.com
2018-04-06 15:29:48

linux命令:cut -d'/' -f3 file | sort | uniq -c -c uniq | sort | file -f3 -d'/' cut cut -d'/' -f3 file | sort | uniq -crootopen.com
linux命令:cut -d'/' -f3 file | sort | uniq -c -c uniq | sort | file -f3 -d'/' cut cut -d'/' -f3 file | sort | uniq -crootopen.com
2018-04-18 01:14:48

linux命令:cut -d: -f1 /etc/passwd | sort sort | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | sortrootopen.com
linux命令:cut -d: -f1 /etc/passwd | sort sort | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | sortrootopen.com
2018-02-09 12:52:48

linux命令:cut -f 1 three-column.txt > first-column.txt first-column.txt > three-column.txt 1 -f cut cut -f 1 three-column.txt > first-column.txtrootopen.com
linux命令:cut -f 1 three-column.txt > first-column.txt first-column.txt > three-column.txt 1 -f cut cut -f 1 three-column.txt > first-column.txtrootopen.com
2018-01-09 07:50:48

linux命令:cut -f5 --complement --complement -f5 cut cut -f5 --complementrootopen.com
linux命令:cut -f5 --complement --complement -f5 cut cut -f5 --complementrootopen.com
2018-05-19 11:21:48

linux命令:cut -f2 -d`echo -e '\x01'` file file '\x01'` -e -d`echo -f2 cut cut -f2 -d`echo -e '\x01'` filerootopen.com
linux命令:cut -f2 -d`echo -e '\x01'` file file '\x01'` -e -d`echo -f2 cut cut -f2 -d`echo -e '\x01'` filerootopen.com
2018-03-31 12:16:48

linux命令:cut -f1 -d" " ~/.bash_history | sort | uniq -c | sort -nr | head -n 30 30 -n head | -nr sort | -c uniq | sort | ~/.bash_history " -d" -f1 cut cut -f1 -d" " ~/.bash_history | sort | uniq -c | sort -nr | head -n 30rootopen.com
linux命令:cut -f1 -d" " ~/.bash_history | sort | uniq -c | sort -nr | head -n 30 30 -n head | -nr sort | -c uniq | sort | ~/.bash_history " -d" -f1 cut cut -f1 -d" " ~/.bash_history | sort | uniq -c | sort -nr | head -n 30rootopen.com
2018-01-03 00:38:48

linux命令:cut -f1 -d"<TAB>" -d"<TAB>" -f1 cut cut -f1 -d"<TAB>"rootopen.com
linux命令:cut -f1 -d"<TAB>" -d"<TAB>" -f1 cut cut -f1 -d"<TAB>"rootopen.com
2018-04-09 21:21:48

linux命令:cut -d, -f5 -f5 -d, cut cut -d, -f5rootopen.com
linux命令:cut -d, -f5 -f5 -d, cut cut -d, -f5rootopen.com
2018-05-13 14:53:48

linux命令:cut -c 1-N 1-N -c cut cut -c 1-Nrootopen.com
linux命令:cut -c 1-N 1-N -c cut cut -c 1-Nrootopen.com
2018-04-03 13:28:48

linux命令:cut -c -N -N -c cut cut -c -Nrootopen.com
linux命令:cut -c -N -N -c cut cut -c -Nrootopen.com
2018-02-09 03:13:48

linux命令:cut -d: -f1 /etc/passwd | sort sort | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | sortrootopen.com
linux命令:cut -d: -f1 /etc/passwd | sort sort | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | sortrootopen.com
2018-03-19 15:45:48

linux命令:cut -d: -f1 /etc/passwd | sort sort | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | sortrootopen.com
linux命令:cut -d: -f1 /etc/passwd | sort sort | /etc/passwd -f1 -d: cut cut -d: -f1 /etc/passwd | sortrootopen.com
2018-02-12 09:11:48

linux命令:cut -f 3 | uniq uniq | 3 -f cut cut -f 3 | uniqrootopen.com
linux命令:cut -f 3 | uniq uniq | 3 -f cut cut -f 3 | uniqrootopen.com
2018-04-04 23:49:48

linux命令:cut -d: -f 1 names.txt names.txt 1 -f -d: cut cut -d: -f 1 names.txtrootopen.com
linux命令:cut -d: -f 1 names.txt names.txt 1 -f -d: cut cut -d: -f 1 names.txtrootopen.com
2018-05-27 21:48:48

linux命令:cut -c23-37 /var/log/squid3/access.log | cut -d' ' -f1 | sort | uniq uniq | sort | -f1 ' -d' cut | /var/log/squid3/access.log -c23-37 cut cut -c23-37 /var/log/squid3/access.log | cut -d' ' -f1 | sort | uniqrootopen.com
linux命令:cut -c23-37 /var/log/squid3/access.log | cut -d' ' -f1 | sort | uniq uniq | sort | -f1 ' -d' cut | /var/log/squid3/access.log -c23-37 cut cut -c23-37 /var/log/squid3/access.log | cut -d' ' -f1 | sort | uniqrootopen.com
2018-04-15 14:00:48

linux命令:cut -c 2- < <file> <file> < 2- -c cut cut -c 2- < <file>rootopen.com
linux命令:cut -c 2- < <file> <file> < 2- -c cut cut -c 2- < <file>rootopen.com
2018-04-01 08:55:48

linux命令:cut -d',' -f6 file.csv | sort | uniq uniq | sort | file.csv -f6 -d',' cut cut -d',' -f6 file.csv | sort | uniqrootopen.com
linux命令:cut -d',' -f6 file.csv | sort | uniq uniq | sort | file.csv -f6 -d',' cut cut -d',' -f6 file.csv | sort | uniqrootopen.com
2018-03-14 00:07:48

linux命令:cut -d, -f1 /var/opt/example/dumpfile.130610_subscriber.csv | cut -c3-5 | sort | uniq -c | sed -e 's/^ *//;/^$/d' | awk -F" " '{print $2 "," $1}' > SubsxPrefix.csv SubsxPrefix.csv > $1}' "," $2 '{print " -F" awk | *//;/^$/d' 's/^ -e sed | -c uniq | sort | -c3-5 cut | /var/opt/example/dumpfile.130610_subscriber.csv -f1 -d, cut cut -d, -f1 /var/opt/example/dumpfile.130610_subscriber.csv | cut -c3-5 | sort | uniq -c | sed -e 's/^ *//;/^$/d' | awk -F" " '{print $2 "," $1}' > SubsxPrefix.csvrootopen.com
linux命令:cut -d, -f1 /var/opt/example/dumpfile.130610_subscriber.csv | cut -c3-5 | sort | uniq -c | sed -e 's/^ *//;/^$/d' | awk -F" " '{print $2 "," $1}' > SubsxPrefix.csv SubsxPrefix.csv > $1}' "," $2 '{print " -F" awk | *//;/^$/d' 's/^ -e sed | -c uniq | sort | -c3-5 cut | /var/opt/example/dumpfile.130610_subscriber.csv -f1 -d, cut cut -d, -f1 /var/opt/example/dumpfile.130610_subscriber.csv | cut -c3-5 | sort | uniq -c | sed -e 's/^ *//;/^$/d' | awk -F" " '{print $2 "," $1}' > SubsxPrefix.csvrootopen.com
2018-01-17 07:02:48

linux命令:cut -d ' ' -f 1 /var/log/apache2/access_logs | uniq -c | sort -n -n sort | -c uniq | /var/log/apache2/access_logs 1 -f ' ' -d cut cut -d ' ' -f 1 /var/log/apache2/access_logs | uniq -c | sort -nrootopen.com
linux命令:cut -d ' ' -f 1 /var/log/apache2/access_logs | uniq -c | sort -n -n sort | -c uniq | /var/log/apache2/access_logs 1 -f ' ' -d cut cut -d ' ' -f 1 /var/log/apache2/access_logs | uniq -c | sort -nrootopen.com
2018-02-15 21:54:48

linux命令:cut -d " " -f1,4 access_log | sort | uniq -c | sort -rn | head head | -rn sort | -c uniq | sort | access_log -f1,4 " " -d cut cut -d " " -f1,4 access_log | sort | uniq -c | sort -rn | headrootopen.com
linux命令:cut -d " " -f1,4 access_log | sort | uniq -c | sort -rn | head head | -rn sort | -c uniq | sort | access_log -f1,4 " " -d cut cut -d " " -f1,4 access_log | sort | uniq -c | sort -rn | headrootopen.com
2018-02-28 02:42:48

linux命令:cut -f 2 -d ':' oclHashcat.pot | egrep -oi '[a-z]{1,20}' | sort | uniq > base.pot base.pot > uniq | sort | '[a-z]{1,20}' -oi egrep | oclHashcat.pot ':' -d 2 -f cut cut -f 2 -d ':' oclHashcat.pot | egrep -oi '[a-z]{1,20}' | sort | uniq > base.potrootopen.com
linux命令:cut -f 2 -d ':' oclHashcat.pot | egrep -oi '[a-z]{1,20}' | sort | uniq > base.pot base.pot > uniq | sort | '[a-z]{1,20}' -oi egrep | oclHashcat.pot ':' -d 2 -f cut cut -f 2 -d ':' oclHashcat.pot | egrep -oi '[a-z]{1,20}' | sort | uniq > base.potrootopen.com
2018-01-13 10:24:48

linux命令:cut -d: -f1 /etc/group | sort sort | /etc/group -f1 -d: cut cut -d: -f1 /etc/group | sortrootopen.com
linux命令:cut -d: -f1 /etc/group | sort sort | /etc/group -f1 -d: cut cut -d: -f1 /etc/group | sortrootopen.com
2018-01-20 18:54:48

Linux的Bash命令行(A-Z排序)