How to append one file to another in Linux from the shell?
You can append one file to another using cat
with the >>
(append) redirection operator. For example:
cat file1 >> file2
This appends the contents of file1
to the end of file2
, leaving file2
’s existing content intact.
Notes
>
overwrites (truncates) the existing file content, while>>
appends to it.- If
file2
does not exist,>>
creates it.
Recommended Resource
For a deeper dive into problem-solving and coding efficiency, consider this course from DesignGurus.io:
- Grokking Data Structures & Algorithms for Coding Interviews
Strengthen your algorithmic and data-structure knowledge—critical for building robust scripts and software under any environment.
CONTRIBUTOR
TechGrind