How to Add Text to a File in Linux Via the Command Line


From the point of view of the Linux operating system, all files are just sequences of bytes; Linux does not make any distinction between files containing human-readable text, encoded database tables or executable machine code. The Linux command line, also known as shell, has powerful mechanisms to add contents to a file. In particular, you can append additional text to a Linux file from the command line.

  • Log in to the computer.

  • Launch a shell, by either logging in to text mode or by launching a Terminal window from the graphical desktop.

  • Type the following command into the shell:

    echo "new text" >> /home/fangulo/textFile.txt

    Replace "new text" by the text you want to add to the file, and replace "/home/fangulo/textFile.txt" by the name, with the full path, of the file to which you want to add the text. Press "Enter." When the shell prompts you for a new command, the text will have been added to the file.

Related Searches


  • Photo Credit Images
Promoted By Zergnet


You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!