日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

linux cat 脚本,Linux Shell 脚本攻略 读书笔记 -- 201.cat的几种用法

發(fā)布時(shí)間:2025/4/16 linux 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux cat 脚本,Linux Shell 脚本攻略 读书笔记 -- 201.cat的几种用法 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

cat可以讀取、顯示和拼接文件內(nèi)容

1. 打印單個(gè)文件:

root@debian:/home/chicol/scripts# cat file.txt

This is a line inside file.txt

This is second line inside file.txt

打印多個(gè)文件:

root@debian:/home/chicol/scripts# cat one.txt two.txt

This is line from one.txt

This is line from two.txt

root@debian:/home/chicol/scripts#

2. 讀取標(biāo)準(zhǔn)輸入:

root@debian:/home/chicol/scripts# ls | cat

1

1_12fname.sh

a1

a2

a3

calcu.sh

file.txt

functions.sh

ifs2.sh

ifs.sh

null

one.txt

out.txt

password.sh

printf.sh

sleep.sh

test1.sh

text.txt

three.txt

time_take.sh

tmp.txt

two.txt

將標(biāo)準(zhǔn)輸入和文件內(nèi)容拼接:

root@debian:/home/chicol/scripts# ls | cat - file.txt

1

1_12fname.sh

a1

a2

a3

calcu.sh

file.txt

functions.sh

ifs2.sh

ifs.sh

null

one.txt

out.txt

password.sh

printf.sh

sleep.sh

test1.sh

text.txt

three.txt

time_take.sh

tmp.txt

two.txt

This is a line inside file.txt

This is second line inside file.txt

這里將"-"當(dāng)作stdin文本的文件名。

3. cat打印文件內(nèi)容的幾個(gè)選項(xiàng)用法:

cat -s :當(dāng)文件中有連續(xù)空白行時(shí),使用-s選項(xiàng)打印時(shí),會(huì)去掉多余的空白行,只保留一個(gè)空白行

cat -n: 打印文件內(nèi)容時(shí)顯示行號(hào)

cat -T: 可以區(qū)別顯示制表符和空格,制表符顯示為“^I”

這里來(lái)看下這幾個(gè)選項(xiàng)在一起使用的例子:

root@debian:/home/chicol/scripts# cat three.txt

This is first line.

This is second line

This is third line.

Tab line.

Space line.

root@debian:/home/chicol/scripts# cat -snT three.txt

1 ?This is first line.

2

3 ?This is second line

4

5 ?This is third line.

6 ?^ITab line.

7 ? ? ? ? ?Space line.

root@debian:/home/chicol/scripts#

閱讀(670) | 評(píng)論(0) | 轉(zhuǎn)發(fā)(0) |

總結(jié)

以上是生活随笔為你收集整理的linux cat 脚本,Linux Shell 脚本攻略 读书笔记 -- 201.cat的几种用法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。