cat

连接并打印(显示)文件的内容

语法

  cat [Options] [File]...

串联FILE(S),或标准输入到标准输出

 -A, --show-all           显示不可打印字符,行尾显示“$”

 -b, --number-nonblank    和-n相似,只不过对于空白行不编号

 -e                       等价于 -vE

 -E, --show-ends          显示每行末尾的$

 -n, --number             有1开始对所有输出的行数编号

 -s, --squeeze-blank      当遇到有连续两行以上的空白行,就代换为一行的空白行

 -t                       等效于 -vT

 -T, --show-tabs          将TAB字符显示为^I

-u                       (忽略)

-v, --show-nonprinting   输出版本信息并退出

实例:

显示文件:

$ cat myfile.txt

显示所有.txt文件:

$ cat *.txt

连接两个文件:

 $ cat File1.txt File2.txt > union.txt

如果您需要组合两个文件但也可以消除重复项,可以使用sort unique 来完成

$ sort -u File1.txt File2.txt > unique_union.txt

将文件的内容放入变量

$ my_variable=`cat File3.txt`

cat 命令实例:

linux命令:cat foo.zip | jar xv xv jar | foo.zip cat cat foo.zip | jar xvrootopen.com
linux命令:cat foo.zip | jar xv xv jar | foo.zip cat cat foo.zip | jar xvrootopen.com
2019-02-12 21:24:40

linux命令:cat -n /path/to/file | less less | /path/to/file -n cat cat -n /path/to/file | lessrootopen.com
linux命令:cat -n /path/to/file | less less | /path/to/file -n cat cat -n /path/to/file | lessrootopen.com
2019-01-06 22:21:19

linux命令:cat url.list | parallel -j 8 wget -O {#}.html {} {} {#}.html -O wget 8 -j parallel | url.list cat cat url.list | parallel -j 8 wget -O {#}.html {}rootopen.com
linux命令:cat url.list | parallel -j 8 wget -O {#}.html {} {} {#}.html -O wget 8 -j parallel | url.list cat cat url.list | parallel -j 8 wget -O {#}.html {}rootopen.com
2019-01-06 22:08:50

linux命令:cat ipsum.txt | perl -ne 'print map("$_\n", m/\w+/g);' | tr A-Z a-z | sort | uniq | awk 'length($1) == 4 {print}' {print}' 4 == 'length($1) awk | uniq | sort | a-z A-Z tr | m/\w+/g);' map("$_\n", 'print -ne perl | ipsum.txt cat cat ipsum.txt | perl -ne 'print map("$_\n", m/\w+/g);' | tr A-Z a-z | sort | uniq | awk 'length($1) == 4 {print}'rootopen.com
linux命令:cat ipsum.txt | perl -ne 'print map("$_\n", m/\w+/g);' | tr A-Z a-z | sort | uniq | awk 'length($1) == 4 {print}' {print}' 4 == 'length($1) awk | uniq | sort | a-z A-Z tr | m/\w+/g);' map("$_\n", 'print -ne perl | ipsum.txt cat cat ipsum.txt | perl -ne 'print map("$_\n", m/\w+/g);' | tr A-Z a-z | sort | uniq | awk 'length($1) == 4 {print}'rootopen.com
2018-12-22 21:55:27

linux命令:cat data.json | json-to-js | pbcopy pbcopy | json-to-js | data.json cat cat data.json | json-to-js | pbcopyrootopen.com
linux命令:cat data.json | json-to-js | pbcopy pbcopy | json-to-js | data.json cat cat data.json | json-to-js | pbcopyrootopen.com
2018-12-22 21:35:19

linux命令:cat /tmp/log.data | colrm 1 155 | colrm 60 300 300 60 colrm | 155 1 colrm | /tmp/log.data cat cat /tmp/log.data | colrm 1 155 | colrm 60 300rootopen.com
linux命令:cat /tmp/log.data | colrm 1 155 | colrm 60 300 300 60 colrm | 155 1 colrm | /tmp/log.data cat cat /tmp/log.data | colrm 1 155 | colrm 60 300rootopen.com
2018-12-08 16:50:50

linux命令:cat file.json | jq jq | file.json cat cat file.json | jqrootopen.com
linux命令:cat file.json | jq jq | file.json cat cat file.json | jqrootopen.com
2018-10-05 22:24:40

linux命令:cat words.txt words.txt cat cat words.txtrootopen.com
linux命令:cat words.txt words.txt cat cat words.txtrootopen.com
2018-09-11 09:55:30

linux命令:cat databases.txt | while read db; do docker exec $container_name bash -c "mysqldump -uroot -p\$MYSQL_ROOT_PASSWORD ${db}" | gzip -9 > $HOME/backups/${db}_`date +%Y%m%d_%H%M%S`.sql.gz; done done +%Y%m%d_%H%M%S`.sql.gz; $HOME/backups/${db}_`date > -9 gzip | ${db}" -p\$MYSQL_ROOT_PASSWORD -uroot "mysqldump -c bash $container_name exec docker do db; read while | databases.txt cat cat databases.txt | while read db; do docker exec $container_name bash -c "mysqldump -uroot -p\$MYSQL_ROOT_PASSWORD ${db}" | gzip -9 > $HOME/backups/${db}_`date +%Y%m%d_%H%M%S`.sql.gz; donerootopen.com
linux命令:cat databases.txt | while read db; do docker exec $container_name bash -c "mysqldump -uroot -p\$MYSQL_ROOT_PASSWORD ${db}" | gzip -9 > $HOME/backups/${db}_`date +%Y%m%d_%H%M%S`.sql.gz; done done +%Y%m%d_%H%M%S`.sql.gz; $HOME/backups/${db}_`date > -9 gzip | ${db}" -p\$MYSQL_ROOT_PASSWORD -uroot "mysqldump -c bash $container_name exec docker do db; read while | databases.txt cat cat databases.txt | while read db; do docker exec $container_name bash -c "mysqldump -uroot -p\$MYSQL_ROOT_PASSWORD ${db}" | gzip -9 > $HOME/backups/${db}_`date +%Y%m%d_%H%M%S`.sql.gz; donerootopen.com
2018-09-11 09:55:30

linux命令:cat -T test test -T cat cat -T testrootopen.com
linux命令:cat -T test test -T cat cat -T testrootopen.com
2018-08-20 22:37:20

linux命令:cat -e test test -e cat cat -e testrootopen.com
linux命令:cat -e test test -e cat cat -e testrootopen.com
2018-08-20 22:36:48

linux命令:cat -n song.txt song.txt -n cat cat -n song.txtrootopen.com
linux命令:cat -n song.txt song.txt -n cat cat -n song.txtrootopen.com
2018-08-20 22:34:44

linux命令:cat song.txt | more cat song.txt | less less | song.txt more cat | song.txt cat cat song.txt | more cat song.txt | lessrootopen.com
linux命令:cat song.txt | more cat song.txt | less less | song.txt more cat | song.txt cat cat song.txt | more cat song.txt | lessrootopen.com
2018-08-20 22:33:55

linux命令:cat >test2 >test2 cat cat >test2rootopen.com
linux命令:cat >test2 >test2 cat cat >test2rootopen.com
2018-08-20 22:32:40

linux命令:cat test test1 test1 test cat cat test test1rootopen.com
linux命令:cat test test1 test1 test cat cat test test1rootopen.com
2018-08-20 22:32:00

linux命令:cat /etc/passwd /etc/passwd cat cat /etc/passwdrootopen.com
linux命令:cat /etc/passwd /etc/passwd cat cat /etc/passwdrootopen.com
2018-08-20 22:31:21

linux命令:cat file.txt file.txt cat cat file.txtrootopen.com
linux命令:cat file.txt file.txt cat cat file.txtrootopen.com
2018-08-20 22:30:16

linux命令:cat /proc/meminfo /proc/meminfo cat cat /proc/meminforootopen.com
linux命令:cat /proc/meminfo /proc/meminfo cat cat /proc/meminforootopen.com
2018-08-11 22:10:42

linux命令:cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv' join(";"))]|@csv' | tostring] .Value),([.InstanceId| | =="Name") select(.Key | .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] [.PrivateIpAddress, | '.Reservations[].Instances[] -r jq | aws.json cat cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv'rootopen.com
linux命令:cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv' join(";"))]|@csv' | tostring] .Value),([.InstanceId| | =="Name") select(.Key | .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] [.PrivateIpAddress, | '.Reservations[].Instances[] -r jq | aws.json cat cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv'rootopen.com
2018-08-10 22:12:23

linux命令:cat -v A A -v cat cat -v Arootopen.com
linux命令:cat -v A A -v cat cat -v Arootopen.com
2018-07-22 21:35:55

linux命令:cat text1 tex21 text3 > text text > text3 tex21 text1 cat cat text1 tex21 text3 > textrootopen.com
linux命令:cat text1 tex21 text3 > text text > text3 tex21 text1 cat cat text1 tex21 text3 > textrootopen.com
2018-07-22 21:19:39

linux命令:cat /etc/issue /etc/issue cat cat /etc/issuerootopen.com
linux命令:cat /etc/issue /etc/issue cat cat /etc/issuerootopen.com
2018-06-02 21:06:48

linux命令:cat /proc/cpuinfo /proc/cpuinfo cat cat /proc/cpuinforootopen.com
linux命令:cat /proc/cpuinfo /proc/cpuinfo cat cat /proc/cpuinforootopen.com
2018-03-10 16:27:48

linux命令:cat -n file.txt file.txt -n cat cat -n file.txtrootopen.com
linux命令:cat -n file.txt file.txt -n cat cat -n file.txtrootopen.com
2018-01-14 05:26:48

linux命令:cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys" ~/.ssh/authorized_keys" >> cat ~/.ssh; "mkdir user@machine ssh | ~/.ssh/id_rsa.pub cat cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"rootopen.com
linux命令:cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys" ~/.ssh/authorized_keys" >> cat ~/.ssh; "mkdir user@machine ssh | ~/.ssh/id_rsa.pub cat cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"rootopen.com
2018-03-01 08:17:48

linux命令:cat file.php | perl -p -e 's/(\$|->)(str|arr|obj|int|flt|boo|bool|mix|res)([A-Z])/$1\L$3/g' 's/(\$|->)(str|arr|obj|int|flt|boo|bool|mix|res)([A-Z])/$1\L$3/g' -e -p perl | file.php cat cat file.php | perl -p -e 's/(\$|->)(str|arr|obj|int|flt|boo|bool|mix|res)([A-Z])/$1\L$3/g'rootopen.com
linux命令:cat file.php | perl -p -e 's/(\$|->)(str|arr|obj|int|flt|boo|bool|mix|res)([A-Z])/$1\L$3/g' 's/(\$|->)(str|arr|obj|int|flt|boo|bool|mix|res)([A-Z])/$1\L$3/g' -e -p perl | file.php cat cat file.php | perl -p -e 's/(\$|->)(str|arr|obj|int|flt|boo|bool|mix|res)([A-Z])/$1\L$3/g'rootopen.com
2018-01-27 03:02:48

linux命令:cat -A -A cat cat -Arootopen.com
linux命令:cat -A -A cat cat -Arootopen.com
2018-05-11 17:04:48

linux命令:cat file.txt|perl -ne '$_=~s/\s+/\n/g; print $_;' $_;' print '$_=~s/\s+/\n/g; -ne file.txt|perl cat cat file.txt|perl -ne '$_=~s/\s+/\n/g; print $_;'rootopen.com
linux命令:cat file.txt|perl -ne '$_=~s/\s+/\n/g; print $_;' $_;' print '$_=~s/\s+/\n/g; -ne file.txt|perl cat cat file.txt|perl -ne '$_=~s/\s+/\n/g; print $_;'rootopen.com
2018-03-22 17:11:48

linux命令:cat /proc/<PID>/environ /proc/<PID>/environ cat cat /proc/<PID>/environrootopen.com
linux命令:cat /proc/<PID>/environ /proc/<PID>/environ cat cat /proc/<PID>/environrootopen.com
2018-05-22 21:12:48

linux命令:cat .ssh/id_rsa.pub | ssh hostname 'cat >> .ssh/authorized_keys' .ssh/authorized_keys' >> 'cat hostname ssh | .ssh/id_rsa.pub cat cat .ssh/id_rsa.pub | ssh hostname 'cat >> .ssh/authorized_keys'rootopen.com
linux命令:cat .ssh/id_rsa.pub | ssh hostname 'cat >> .ssh/authorized_keys' .ssh/authorized_keys' >> 'cat hostname ssh | .ssh/id_rsa.pub cat cat .ssh/id_rsa.pub | ssh hostname 'cat >> .ssh/authorized_keys'rootopen.com
2018-04-09 23:55:48

linux命令:cat /dev/null >filename >filename /dev/null cat cat /dev/null >filenamerootopen.com
linux命令:cat /dev/null >filename >filename /dev/null cat cat /dev/null >filenamerootopen.com
2018-01-08 12:59:48

linux命令:cat SomeFile.txt | pbcopy pbcopy | SomeFile.txt cat cat SomeFile.txt | pbcopyrootopen.com
linux命令:cat SomeFile.txt | pbcopy pbcopy | SomeFile.txt cat cat SomeFile.txt | pbcopyrootopen.com
2018-04-06 19:17:48

linux命令:cat welcome | wall wall | welcome cat cat welcome | wallrootopen.com
linux命令:cat welcome | wall wall | welcome cat cat welcome | wallrootopen.com
2018-05-17 11:15:48

linux命令:cat -n $file | tail -n 100 && head -n number-of-lines-you-want-to-keep > newfile newfile > number-of-lines-you-want-to-keep -n head && 100 -n tail | $file -n cat cat -n $file | tail -n 100 && head -n number-of-lines-you-want-to-keep > newfilerootopen.com
linux命令:cat -n $file | tail -n 100 && head -n number-of-lines-you-want-to-keep > newfile newfile > number-of-lines-you-want-to-keep -n head && 100 -n tail | $file -n cat cat -n $file | tail -n 100 && head -n number-of-lines-you-want-to-keep > newfilerootopen.com
2018-06-07 23:58:48

linux命令:cat ~/.ssh/*.pub | ssh user@remote-system 'umask 077; cat >>.ssh/authorized_keys' >>.ssh/authorized_keys' cat 077; 'umask user@remote-system ssh | ~/.ssh/*.pub cat cat ~/.ssh/*.pub | ssh user@remote-system 'umask 077; cat >>.ssh/authorized_keys'rootopen.com
linux命令:cat ~/.ssh/*.pub | ssh user@remote-system 'umask 077; cat >>.ssh/authorized_keys' >>.ssh/authorized_keys' cat 077; 'umask user@remote-system ssh | ~/.ssh/*.pub cat cat ~/.ssh/*.pub | ssh user@remote-system 'umask 077; cat >>.ssh/authorized_keys'rootopen.com
2017-12-29 16:47:48

linux命令:cat /dev/urandom | gzip -9 > /dev/null & & /dev/null > -9 gzip | /dev/urandom cat cat /dev/urandom | gzip -9 > /dev/null &rootopen.com
linux命令:cat /dev/urandom | gzip -9 > /dev/null & & /dev/null > -9 gzip | /dev/urandom cat cat /dev/urandom | gzip -9 > /dev/null &rootopen.com
2018-04-12 05:47:48

linux命令:cat /proc/cpuinfo /proc/cpuinfo cat cat /proc/cpuinforootopen.com
linux命令:cat /proc/cpuinfo /proc/cpuinfo cat cat /proc/cpuinforootopen.com
2018-05-12 21:57:48

linux命令:cat /dev/mem > /dev/audio /dev/audio > /dev/mem cat cat /dev/mem > /dev/audiorootopen.com
linux命令:cat /dev/mem > /dev/audio /dev/audio > /dev/mem cat cat /dev/mem > /dev/audiorootopen.com
2018-02-04 04:50:48

linux命令:cat /dev/urandom > /dev/dsp /dev/dsp > /dev/urandom cat cat /dev/urandom > /dev/dsprootopen.com
linux命令:cat /dev/urandom > /dev/dsp /dev/dsp > /dev/urandom cat cat /dev/urandom > /dev/dsprootopen.com
2018-05-31 18:21:48

linux命令:cat .ssh/id_dsa.pub | ssh elsewhere "[ -d .ssh ] || mkdir .ssh ; cat >> .ssh/authorized_keys" .ssh/authorized_keys" >> cat ; .ssh mkdir || ] .ssh -d "[ elsewhere ssh | .ssh/id_dsa.pub cat cat .ssh/id_dsa.pub | ssh elsewhere "[ -d .ssh ] || mkdir .ssh ; cat >> .ssh/authorized_keys"rootopen.com
linux命令:cat .ssh/id_dsa.pub | ssh elsewhere "[ -d .ssh ] || mkdir .ssh ; cat >> .ssh/authorized_keys" .ssh/authorized_keys" >> cat ; .ssh mkdir || ] .ssh -d "[ elsewhere ssh | .ssh/id_dsa.pub cat cat .ssh/id_dsa.pub | ssh elsewhere "[ -d .ssh ] || mkdir .ssh ; cat >> .ssh/authorized_keys"rootopen.com
2018-02-04 01:18:48

linux命令:cat somefilehere.txt | ssh-xfer nametocallfile.txt - - nametocallfile.txt ssh-xfer | somefilehere.txt cat cat somefilehere.txt | ssh-xfer nametocallfile.txt -rootopen.com
linux命令:cat somefilehere.txt | ssh-xfer nametocallfile.txt - - nametocallfile.txt ssh-xfer | somefilehere.txt cat cat somefilehere.txt | ssh-xfer nametocallfile.txt -rootopen.com
2018-03-11 13:21:48

linux命令:cat foo.csv bar.csv | sort -t "," -k 2 | uniq uniq | 2 -k "," -t sort | bar.csv foo.csv cat cat foo.csv bar.csv | sort -t "," -k 2 | uniqrootopen.com
linux命令:cat foo.csv bar.csv | sort -t "," -k 2 | uniq uniq | 2 -k "," -t sort | bar.csv foo.csv cat cat foo.csv bar.csv | sort -t "," -k 2 | uniqrootopen.com
2018-03-25 07:51:48

linux命令:cat /dev/tty > FILE FILE > /dev/tty cat cat /dev/tty > FILErootopen.com
linux命令:cat /dev/tty > FILE FILE > /dev/tty cat cat /dev/tty > FILErootopen.com
2018-02-27 01:00:48

linux命令:cat /etc/*-release /etc/*-release cat cat /etc/*-releaserootopen.com
linux命令:cat /etc/*-release /etc/*-release cat cat /etc/*-releaserootopen.com
2018-02-14 11:02:48

linux命令:cat file1.txt | uniq > file2.txt file2.txt > uniq | file1.txt cat cat file1.txt | uniq > file2.txtrootopen.com
linux命令:cat file1.txt | uniq > file2.txt file2.txt > uniq | file1.txt cat cat file1.txt | uniq > file2.txtrootopen.com
2017-12-31 20:32:48

linux命令:cat /dev/zero > /dev/null & & /dev/null > /dev/zero cat cat /dev/zero > /dev/null &rootopen.com
linux命令:cat /dev/zero > /dev/null & & /dev/null > /dev/zero cat cat /dev/zero > /dev/null &rootopen.com
2018-02-24 00:53:48

linux命令:cat $(ls -tr | tail -1) | awk '{ a[$1] += 1; } END { for(i in a) printf("%d, %s\n", a[i], i ); }' | sort -n | tail -25 -25 tail | -n sort | }' ); i a[i], %s\n", printf("%d, a) in for(i { END } 1; += a[$1] '{ awk | -1) tail | -tr $(ls cat cat $(ls -tr | tail -1) | awk '{ a[$1] += 1; } END { for(i in a) printf("%d, %s\n", a[i], i ); }' | sort -n | tail -25rootopen.com
linux命令:cat $(ls -tr | tail -1) | awk '{ a[$1] += 1; } END { for(i in a) printf("%d, %s\n", a[i], i ); }' | sort -n | tail -25 -25 tail | -n sort | }' ); i a[i], %s\n", printf("%d, a) in for(i { END } 1; += a[$1] '{ awk | -1) tail | -tr $(ls cat cat $(ls -tr | tail -1) | awk '{ a[$1] += 1; } END { for(i in a) printf("%d, %s\n", a[i], i ); }' | sort -n | tail -25rootopen.com
2018-02-17 17:33:48

linux命令:cat <( command1 arg arg ) <( command2 arg ) ... ... ) arg command2 <( ) arg arg command1 <( cat cat <( command1 arg arg ) <( command2 arg ) ...rootopen.com
linux命令:cat <( command1 arg arg ) <( command2 arg ) ... ... ) arg command2 <( ) arg arg command1 <( cat cat <( command1 arg arg ) <( command2 arg ) ...rootopen.com
2018-01-04 20:59:48

linux命令:cat /path/to/7z.sfx /path/to/archive > archive.exe archive.exe > /path/to/archive /path/to/7z.sfx cat cat /path/to/7z.sfx /path/to/archive > archive.exerootopen.com
linux命令:cat /path/to/7z.sfx /path/to/archive > archive.exe archive.exe > /path/to/archive /path/to/7z.sfx cat cat /path/to/7z.sfx /path/to/archive > archive.exerootopen.com
2018-03-13 21:23:48

linux命令:cat count.txt | awk '{ sum+=$1} END {print sum}' sum}' {print END sum+=$1} '{ awk | count.txt cat cat count.txt | awk '{ sum+=$1} END {print sum}'rootopen.com
linux命令:cat count.txt | awk '{ sum+=$1} END {print sum}' sum}' {print END sum+=$1} '{ awk | count.txt cat cat count.txt | awk '{ sum+=$1} END {print sum}'rootopen.com
2018-05-27 05:33:48

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