

To copy the file’s data (the content of one file into another) cat file1 > file2

If any file with file name file2 exists in the current directory then it is opened (in append mode). This command creates a new file file2 (in write mode) if it doesn’t exist in the present working directory. To add the contents at end of a file cat > file2 If any file with file name file3 exists in the current directory then it is overwritten with the contents of file1 & file2. This command creates a new file file3 with the contents of file1 & file2 if file3 doesn’t exist in the present working directory. To concatenate files - adding the contents of two files into a new file or existing file cat >file2 This command simply prints the contents of file1 on the terminal screen. Note: After writing the text into the file, press ctrl+d to save and exit from the writing mode. If any file with file name file1 exists in the current directory then it is overwritten. This command creates a new file file1 (in write mode) if it doesn’t exist in the present working directory. To create files and write the data into them cat >file1 Major operations that can be done using it are as follows: We cannot edit a file using the cat command. It is the most universal command/tool for creating files on Linux systems. All of them have their own purpose and benefits. There are mainly six ways of creating files in Linux.
