在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Linux/ cat命令
which命令
ss命令
cp命令使用示例
ps命令
find命令
grep命令
scp命令
rmdir命令
df命令示例
less命令
du命令示例
chown命令示例
route命令
ping命令
more命令
mv命令
ln命令
mkdir命令
rm命令
find命令常用參數(shù)示例
cat命令
find命令-xargs參數(shù)
touch命令
traceroute命令
gzip命令示例
date命令
ls命令
vmstat命令
lsof命令
diff命令
head命令
watch命令
ifconfig命令
cd命令
tail命令
iostat命令
chgrp命令示例
free命令
find命令-exec參數(shù)
tar命令打包解壓示例
cal命令
at命令
netstat命令
wc命令
chmod命令示例
pwd命令
top命令詳解示例
crontab命令(Linux定時(shí)任務(wù))
whereis命令
Linux命令大全教程
nl命令
rcp命令
locate命令

cat命令

cat命令的用途是連接文件或標(biāo)準(zhǔn)輸入并打印。這個(gè)命令常用來(lái)顯示文件內(nèi)容,或者將幾個(gè)文件連接起來(lái)顯示,或者從標(biāo)準(zhǔn)輸入讀取內(nèi)容并顯示,它常與重定向符號(hào)配合使用。

1.命令格式

cat [選項(xiàng)] [文件]…

2.命令功能

cat主要有三大功能:

  1. 一次顯示整個(gè)文件:cat filename
  2. 從鍵盤創(chuàng)建一個(gè)文件:cat > filename 只能創(chuàng)建新文件,不能編輯已有文件.
  3. 將幾個(gè)文件合并為一個(gè)文件:cat file1 file2 > file
    命令參數(shù):
    • -A, --show-all 等價(jià)于 -vET
    • -b, --number-nonblank 對(duì)非空輸出行編號(hào)
    • -e 等價(jià)于 -vE
    • -E, --show-ends 在每行結(jié)束處顯示$
    • -n, --number 對(duì)輸出的所有行編號(hào),由1開(kāi)始對(duì)所有輸出的行數(shù)編號(hào)
    • -s, --squeeze-blank 有連續(xù)兩行以上的空白行,就代換為一行的空白行
    • -t-vT 等價(jià)
    • -T, --show-tabs 將跳格字符顯示為 ^I
    • -u (被忽略)
    • -v, --show-nonprinting 使用 ^M- 引用,除了 LFDTAB 之外

4.使用實(shí)例

實(shí)例一

mylog1.log 的文件內(nèi)容加上行號(hào)后輸入 mylog2.log 這個(gè)文件里。
命令:

cat -n mylog1.log mylog2.log

輸出:

[yiibai@localhost test]$ cat mylog1.log
this is line 1
this is line 2
[yiibai@localhost test]$ cat mylog2.log
log2 this is line 1
log2 this is line 2
log2 this is line 3
[yiibai@localhost test]$ cat -n mylog1.log mylog2.log
     1  this is line 1
     2  this is line 2
     3  log2 this is line 1
     4  log2 this is line 2
     5  log2 this is line 3
[yiibai@localhost test]$

實(shí)例二

mylog1.logmylog2.log 的文件內(nèi)容加上行號(hào)(空白行不加)之后將內(nèi)容附加到 log.log 里。
命令:

cat -b mylog1.log mylog2.log log.log

輸出:

yiibai@localhost test]$ cat -b mylog1.log mylog2.log >> log.log
[yiibai@localhost test]$ cat log.log
     1  this is line 1
     2  this is line 2
     3  log2 this is line 1
     4  log2 this is line 2
     5  log2 this is line 3
[yiibai@localhost test]$

實(shí)例三

使用here doc來(lái)生成文件

[yiibai@localhost test]$ cat >log.txt <<EOF
> Hello
> World
> Linux command
> PWD=$(pwd)
> EOF
[yiibai@localhost test]$ ls -l log.txt
-rw-rw-r--. 1 yiibai yiibai 49 Feb 13 03:20 log.txt
[yiibai@localhost test]$ cat log.txt
Hello
World
Linux command
PWD=/home/yiibai/test
[yiibai@localhost test]$

上一篇:rmdir命令下一篇:ps命令