![]() The cat command can use the "*" wildcard character to list the content of all files available in the current directory. ![]() ![]() List Contents of All Specified File Types The expected output will show the "$" symbol at the end of each line of the content. The EOL characters are known as non-printing characters and they are represented by the dollar ("$") symbol. The user can also use the "-E" option to view the EOL ( End of Line) character in the contents of the file. Moving forward, we need to verify whether the new file stores the concatenated content of both files or not: $ lsĬoncatenate Multiple Files in Linux 7. The above command will read the content of the “ tecmint1.txt” and “ tecmint2.txt” files and will write them in a new file “ cat_tecmint.txt”. Let’s run the command to concatenate/merge contents of the “ tecmint1.txt” and “ tecmint2.txt” files and store the result in a new file named “ cat_tecmint.txt”: $ cat tecmint1.txt tecmint2.txt > cat_tecmint.txt Append Contents of Multiple Files Into One File on LinuxĪs mentioned earlier, the cat command can be utilized for concatenation purposes. The next step is that you verify if the new file has been created successfully by running: $ lsĬopy Contents From One File to Another 6. $ cat Tecmint_tutorial.txt > New_file.txt Here, ">" operator will read the content of the “ Tecmint_tutorial.txt” file sequentially and will place it into a new file named “ New_file.txt“. Sometimes, the user wants to create a copy of the contents stored in a file into a new file for different purposes, such as backup. Copy File Content to Another File in Linux Now let’s verify if the content has been appended to the existing contents stored in the file: $ cat Tecmint_tutorial.txtĬheck File Contents 5. Type or paste the content that you want to append to this file and press the "CTRL + D" keys: Append Text to a File One of the benefits of the cat command is that it can append the content to an existing file using the ">" symbol (known as “append redirection operator”) will append/combine the additional content to an existing file “ Tecmint_tutorial.txt“. You can verify the file’s creation by using the ls command and use the cat command to view the content of the newly created file: $ ls Write the content for the file and press the “CTRL + D” keys to save and exit the file: Create New File and Add Content Otherwise, the command will overwrite the content of the existing file.Īfter executing the command, an indicator will blink in the new line. Note: If you want to create a new file, be careful that a file with the same name does not exist already. The user can create a new file and save content in it with the ">" symbol (known as the “output redirection operator”) will redirect the output of the command to the file specified by the filename “ Tecmint_tutorial.txt” as shown. The first two lines are of file “ tecmint1.txt”, whereas the last line of the output is the content of the “ tecmint2.txt” file. In the above output, we can see the contents of both files in the terminal. ![]() The cat command can also be utilized to show the contents of more than one file by providing the file names separated by space as shown: $ cat tecmint1.txt tecmint2.txt Display Contents of Multiple Files in Linux Here in the command, the content of the file “ tecmint1.txt” which is located in the “ Documents” directory will display. For that purpose, provide the name of the file with no option as shown. The basic functionality of the cat command is to display the content of an existing file in Linux. Let’s explore different examples to harness the power of cat command. Note: To read in detail about all the available options of the cat command, execute the "cat -help" command in your Linux terminal: $ cat -help Append File Content to End of Another File Append Contents of Multiple Files Into One File on Linux
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |