Cat command in Linux with examples

您所在的位置:网站首页 海关增值税计算公式表 Cat command in Linux with examples

Cat command in Linux with examples

2024-07-14 08:07:27| 来源: 网络整理| 查看: 265

Cat(concatenate) command is very frequently used in Linux. It reads data from the file and gives their content as output. It helps us to create, view, concatenate files. So let us see some frequently used cat commands. 

1) To view a single file Command:  

$cat filename

Output  

It will show content of given filename

2) To view multiple files Command:  

$cat file1 file2

Output  

This will show the content of file1 and file2.

3) To view contents of a file preceding with line numbers. Command:  

$cat -n filename

Output  

It will show content with line number example:-cat-n geeks.txt 1)This is geeks 2)A unique array

4) Create a file Command:  

$ cat > newfile

Output  

Will create a file named newfile

5) Copy the contents of one file to another file. Command:  

$cat [filename-whose-contents-is-to-be-copied] > [destination-filename]

Output  

The content will be copied in destination file

6) Cat command can suppress repeated empty lines in output Command:  

$cat -s geeks.txt

Output  

Will suppress repeated empty lines in output

7) Cat command can append the contents of one file to the end of another file. Command:  

$cat file1 >> file2

Output  

Will append the contents of one file to the end of another file

8) Cat command can display content in reverse order using tac command. Command:  

$tac filename

Output  

Will display content in reverse order

9) Cat command can highlight the end of line. Command:  

$cat -E "filename"

Output  

Will highlight the end of line

10) If you want to use the -v, -E and -T option together, then instead of writing -vET in the command, you can just use the -A command line option. Command  

$cat -A "filename"

11) Cat command to open dashed files. Command:  

$cat -- "-dashfile"

Output  

Will display the content of -dashfile

12) Cat command if the file has a lot of content and can’t fit in the terminal. Command:  

$cat "filename" | more

Output  

Will show that much content, which could fit in terminal and will ask to show more.

13) Cat command to merge the contents of multiple files. Command:  

$cat "filename1" "filename2" "filename3" > "merged_filename"

Output  

Will merge the contents of file in respective order and will insert that content in "merged_filename".

14) Cat command to display the content of all text files in the folder. Command:  

$cat *.txt

Output  

Will show the content of all text files present in the folder.

15) Cat command to write in an already existing file. 

Command :

$cat >> geeks.txt The newly added text.

Output

Will append the text "The newly added text." to the end of the file.

?list=PLqM7alHXFySFc4KtwEZTANgmyJm3NqS_L 

 

This article is contributed by Pranav. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to [email protected]. See your article appearing on the GeeksforGeeks main page and help other Geeks. 

 

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

 

My Personal Notes arrow_drop_up


【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭