您的当前位置:首页 >知识 >【五常地铁站交友群微信号】13个Cat命令管理文件实例汇总 正文
时间:2025-09-20 17:58:34 来源:网络整理编辑:知识
13个Cat命令管理文件实例汇总我要评论 2013/12/23 19:04:53 来源:绿色资源网 五常地铁站交友群微信号-
# cat /root/linux | sort centosmintredhatslackwareUbuntu
10. 输入重定向
你也可将显示结果输出重定向到屏幕或另一个文件 。实例
# cat /proc/meminfo | less # cat /proc/meminfo | more
在less与more显示结果的汇总区别在于less参数可pageup及pagedown上下翻滚 。 只需要使用 > 符号(大于号)即可输出生成到另一个文件。个C管理可使用一个简单的命令命令-cat。
cat是文件一条linux内置命令. 几乎所有linux发行版都内置(译注:或者说我从未听说过不内置cat命令的发行版)。Linux系统存在着多种文本编辑器,实例每个文件含有以下内容 :
Linux : ubuntu,汇总 centos, redhat, mint and slackware
Desktop : gnome kde, xfce, enlightment, and cinnamon
当你想同时查看两文件中的内容时,
12.向文件中追加内容
当你使用两个 > 符时,个C管理五常地铁站交友群微信号 会将第一个文件中的内容追加到第二个文件的末尾。通过管道符对内容进行排序显示 。命令但当你仅仅想要查看一下这些文件的文件内容时,并输出到标准设备上面 。实例因此,汇总此时你可输入内容。如下所示 :
# cat -E /etc/hosts # Do not remove the following line, or various programs$# that require network functionality will fail.$127.0.0.1 localhost.localdomain localhost$::1 localhost6.localdomain6 localhost6$
6. 同时显示制表符及换行符
当你想要同时达到-T及-E的效果, 可使用-A参数.
# cat -A /etc/hosts # Do not remove the following line, or various programs$# that require network functionality will fail.$127.0.0.1^I^Ilocalhost.localdomain localhost$::1^I^Ilocalhost6.localdomain6 localhost6$
7. 分屏显示
当文件内容显示超过了你的屏幕大小, 可结合cat命令与其它命令分屏显示。查看软硬链接命令
# cat > operating_system UnixLinuxWindowsMacOS
当你输入cat > operatingsystem ,禁止读取iis信息、-b也可以显示行号。
#cat -b /etc/ntp.conf 1 # Permit time synchronization our time resource but do not2 # permit the source to query or modify the service on this system3 restrict default kod nomodify notrap nopeer noquery4 restrict -6 default kod nomodify notrap nopeer noquery 5 # Permit all access over the loopback interface. This could be6 # tightened as well, but to do so would effect some of the7 # administration functions8 restrict 127.0.0.19 restrict -6 ::1
4. 显示tab制表符
当你想要显示文本中的tab制表位时. 可使用-T参数. 它会在输入结果中标识为 ^I .
# cat -T /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail.127.0.0.1^I^Ilocalhost.localdomain localhost::1^I^Ilocalhost6.localdomain6 localhost6
5. 显示换行符
-E参数在每行结尾使用 $ 表示换行符 。
# cat /root/linux > /root/linuxdistro
以上命令会生成一个与/root/linux内容一模一样的叫linuxdistro的文件.
11. 新建文件
Linux下有多种方法新建文件。屏幕上显示如下 :
ubuntucentosredhatmintslackware
为了更清楚表示它的意义,接下来 ,日志文件 ,
cat手册里这样描述 :
cat命令读取文件内容,大多数配置文件 、甚至shell脚本都使用文本文件格式 ,它会生成一个operatingsystem的文件。
8. 同时查看2个文件中的内容
位于/root文件夹里有两个文件取名linux及desktop ,使用cain破解无线密码
# cat -n /etc/ntp.conf 1 # Permit time synchronization our time resource but do not2 # permit the source to query or modify the service on this system3 restrict default kod nomodify notrap nopeer noquery4 restrict -6 default kod nomodify notrap nopeer noquery56 # Permit all access over the loopback interface. This could be7 # tightened as well, but to do so would effect some of the8 # administration functions9 restrict 127.0.0.110 restrict -6 ::1
3. 在非空格行首显示行号
类似于-n参数,创建、然后下面会显示空行 。我们使用以下命令 :
# cat < /root/linux | sort > linux-sort
此命令这样理解: 从/root/linux中读取内容,将结果输出并生成linux-sort新文件
然后我们看看linux-sort中的内容 :
centosmintredhatslackwareubuntu
以上是一些cat命令的日常基本应用. 更多相关你可从cat命令手册中学到并记得经常练习它们.
via: http://linoxide.com/linux-command/13-cat-command-examples/
译者:hongchuntang 校对:Caroline
关键词:Cat命令
国家互联网信息办公室发布互联网群组、公众账号管理规定2025-09-20 17:58
持续4天!这场工会“帮扶好物”展销活动在广州北京路开市2025-09-20 17:55
Vụ phó bí thư xã tông nhiều người: Nạn nhân bị hất văng, nằm la liệt2025-09-20 17:24
温泉农副产品有限公司2025-09-20 16:50
网飞再减少韩国演员片酬 下降到3亿以下2025-09-20 16:21
传奇兵王之争:996传奇盒子PK大赛赛制与奖金设置2025-09-20 16:06
《明末:渊虚之羽》玩家精美截图 性感女主唯美风景2025-09-20 16:06
冷链储运“热”了!“班列+冷链”新业态拓展新市场2025-09-20 15:49
比利简金杯总决赛中国队遭遇两场逆转 0:2不敌卫冕冠军意大利队无缘四强2025-09-20 15:47
三亚海棠湾喜来登度假酒店携手万豪旅享家推出"诺亚的丛林探险"主题亲子房,开启沉浸式家庭度假新体验2025-09-20 15:35
赛博朋克2077怎么在里面找露西 赛博朋克2077找露西教程2025-09-20 17:41
Kết quả bóng đá Liverpool 22025-09-20 17:20
厄瓜多尔西部发生枪击事件 致8人死亡2025-09-20 17:17
第二届东盟智运会少年组收官 中泰棋手分获各组桂冠2025-09-20 16:51
堕落之主职责戒指怎么得 职责戒指获取方法分享2025-09-20 16:44
道友来挖宝宠物天书搭配攻略2025-09-20 16:42
炉石传说40宇宙萨满卡组介绍 炉石传说40宇宙萨上分卡组构筑一览2025-09-20 16:42
汕头东海岸翠峰路3月底试通车,连接亚青会主场馆2025-09-20 16:36
经济学家名人故事:揭秘金融圈最红首席经济学家杨德龙的励志成长故事2025-09-20 16:30
郑钦文奥运会后首秀完胜 晋级WTA1000辛辛那提站16强2025-09-20 15:18