bash:cat
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
bash:cat [2021/01/26 11:44] – [Enter data between 2 files] peter | bash: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 | ||
- | </ | ||
- | |||
- | type into the terminal: | ||
- | |||
- | <code bash> | ||
- | aaa | ||
- | bbb | ||
- | ccc | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | Press **CTRL+D** to stop inputting and save file. | ||
- | |||
- | * This can only be done at the start of a new line; so **< | ||
- | |||
- | This would have created the file **list.txt**. | ||
- | </ | ||
- | |||
- | |||
- | ---- | ||
- | |||
- | ===== Display a file ===== | ||
- | |||
- | <code bash> | ||
- | cat list.txt | ||
- | </ | ||
- | |||
- | returns: | ||
- | |||
- | <code bash> | ||
- | aaa | ||
- | bbb | ||
- | ccc | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Concatenate multiple files ===== | ||
- | |||
- | Create another file, named list2.txt, containing: | ||
- | |||
- | <code bash> | ||
- | ddd | ||
- | eee | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ==== Do the concatenation ==== | ||
- | |||
- | <code bash> | ||
- | cat list.txt list2.txt | ||
- | </ | ||
- | |||
- | returns: | ||
- | |||
- | <code bash> | ||
- | aaa | ||
- | bbb | ||
- | ccc | ||
- | ddd | ||
- | eee | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | === Concatenate to a new file === | ||
- | |||
- | <code bash> | ||
- | cat list.txt list2.txt > list3.txt | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | === Display this new file === | ||
- | |||
- | <code bash> | ||
- | cat list3.txt | ||
- | </ | ||
- | |||
- | returns: | ||
- | |||
- | <code bash> | ||
- | aaa | ||
- | bbb | ||
- | ccc | ||
- | ddd | ||
- | eee | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Append to a file ===== | ||
- | |||
- | <code bash> | ||
- | cat >> list3.txt | ||
- | </ | ||
- | |||
- | enter: | ||
- | |||
- | < | ||
- | fff | ||
- | ggg | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | Press **CTRL+D** to stop inputting and save file. | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | === Display the appended file === | ||
- | |||
- | <code bash> | ||
- | cat list3.txt | ||
- | </ | ||
- | |||
- | returns: | ||
- | |||
- | <code bash> | ||
- | aaa | ||
- | bbb | ||
- | ccc | ||
- | ddd | ||
- | eee | ||
- | fff | ||
- | ggg | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Place data between 2 files ===== | ||
- | |||
- | <code bash> | ||
- | cat list.txt - list2.txt > list4.txt | ||
- | </ | ||
- | |||
- | enter: | ||
- | |||
- | <code bash> | ||
- | hhh | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | Press **CTRL+D** to stop inputting and save file. | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | === Display the file === | ||
- | |||
- | <code bash> | ||
- | cat list4.txt | ||
- | </ | ||
- | |||
- | returns: | ||
- | |||
- | <code bash> | ||
- | aaa | ||
- | bbb | ||
- | ccc | ||
- | hhh | ||
- | ddd | ||
- | eee | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | **NOTE: | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ==== Join split binary files ==== | ||
- | |||
- | <code bash> | ||
- | cat video.001 video.002 video.003 > vid.avi | ||
- | </ | ||
- | |||
- | |||
bash/cat.1611661465.txt.gz · Last modified: 2021/01/26 11:44 by peter