bash:cat
This is an old revision of the document!
Table of Contents
BASH - cat
cat is used to concatenate or write files, text or binary.
—
Write a file
cat > list.txt
type into the terminal:
aaa bbb ccc
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.
Display a file
cat list.txt
returns:
aaa bbb ccc
Concatenate multiple files
Create another file, named list2.txt, containing:
ddd
eee
Do the concatenation
Concatenate to a new file
cat list.txt list2.txt > list3.txt
cat list3.txt
returns:
aaa
bbb
ccc
ddd
eee
Append to a file
cat >> list3.txt
enter:
fff ggg
Press CTRL+D to stop inputting and save file.
Display the appended file
cat list3.txt
returns:
aaa
bbb
ccc
ddd
eee
fff
ggg
Enter data into the middle of the file
cat list.txt - list2.txt > list4.txt
enter:
hhh
Press CTRL+D to stop inputting and save file.
Display the file
cat list4.txt
returns:
aaa
bbb
ccc
hhh
ddd
eee
NOTE: The hhh data is showing in the middle of the data from the 2 input files.
cat video.001 video.002 video.003 > vid.avi
Joining split binary file.
bash/cat.1610201879.txt.gz · Last modified: 2021/01/09 14:17 by peter