User Tools

Site Tools


bash:cat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
bash:cat [2021/01/26 11:44] – [Enter data between 2 files] peterbash:cat [2021/01/26 15:55] (current) – removed peter
Line 1: Line 1:
-====== BASH - cat ====== 
- 
-**cat** is used to concatenate or write files, text or binary. 
- 
----- 
- 
-===== Write a file ===== 
- 
-<code bash> 
-cat > list.txt 
-</code> 
- 
-type into the terminal: 
- 
-<code bash> 
-aaa 
-bbb 
-ccc 
-</code> 
- 
-<WRAP info> 
-Press **CTRL+D** to stop inputting and save file. 
- 
-  * This can only be done at the start of a new line; so **<ENTER>** needs to be done against the last line before being able to do a **CTRL-D**. 
- 
-This would have created the file **list.txt**. 
-</WRAP> 
- 
- 
----- 
- 
-===== Display a file ===== 
- 
-<code bash> 
-cat list.txt 
-</code> 
- 
-returns: 
- 
-<code bash> 
-aaa 
-bbb 
-ccc 
-</code> 
- 
----- 
- 
-===== Concatenate multiple files ===== 
- 
-Create another file, named list2.txt, containing: 
- 
-<code bash> 
-ddd 
-eee 
-</code> 
- 
----- 
- 
-==== Do the concatenation ==== 
- 
-<code bash> 
-cat list.txt list2.txt 
-</code> 
- 
-returns: 
- 
-<code bash> 
-aaa 
-bbb 
-ccc 
-ddd 
-eee 
-</code> 
- 
----- 
- 
-=== Concatenate to a new file === 
- 
-<code bash> 
-cat list.txt list2.txt > list3.txt 
-</code> 
- 
----- 
- 
-=== Display this new file === 
- 
-<code bash> 
-cat list3.txt 
-</code> 
- 
-returns: 
- 
-<code bash> 
-aaa 
-bbb 
-ccc 
-ddd 
-eee 
-</code> 
- 
----- 
- 
-===== Append to a file ===== 
- 
-<code bash> 
-cat >> list3.txt 
-</code> 
- 
-enter: 
- 
-<code> 
-fff 
-ggg 
-</code> 
- 
-<WRAP info> 
-Press **CTRL+D** to stop inputting and save file. 
-</WRAP> 
- 
----- 
- 
-=== Display the appended file === 
- 
-<code bash> 
-cat list3.txt 
-</code> 
- 
-returns: 
- 
-<code bash> 
-aaa 
-bbb 
-ccc 
-ddd 
-eee 
-fff 
-ggg 
-</code> 
- 
----- 
- 
-===== Enter data between 2 files ===== 
- 
-<code bash> 
-cat list.txt - list2.txt > list4.txt 
-</code> 
- 
-enter: 
- 
-<code bash> 
-hhh 
-</code> 
- 
-<WRAP info> 
-Press **CTRL+D** to stop inputting and save file. 
-</WRAP> 
- 
----- 
- 
-=== Display the file === 
- 
-<code bash> 
-cat list4.txt 
-</code> 
- 
-returns: 
- 
-<code bash> 
-aaa 
-bbb 
-ccc 
-hhh 
-ddd 
-eee 
-</code> 
- 
-<WRAP info> 
-**NOTE:**  The **hhh** data is showing in the middle of the data from the 2 input files. 
-</WRAP> 
- 
----- 
- 
-==== Join split binary files ==== 
- 
-<code bash> 
-cat video.001 video.002 video.003 > vid.avi 
-</code> 
- 
- 
  
bash/cat.1611661449.txt.gz · Last modified: 2021/01/26 11:44 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki