Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easiest way to add a text to the beginning of another text file in Command Line (Windows)

What is the easiest way to add a text to the beginning of another text file in Command Line (Windows)?

like image 480
dr. evil Avatar asked Feb 15 '09 11:02

dr. evil


People also ask

How do you add text to a file in cmd?

But, if you would like to add some text to the file, you can type in after this, like this: cat >> new. txt This is some text in the file from command line. To stop editing and saving in the file, simply type CTRL+C, it will create, save and exit the file.

How do I add text to the beginning of a bash file?

To add the text at the beginning of the existing first line, use the -n argument of echo. Note that although Bash or many other shells do not have a limit on the size of a variable, however, the size may be limited based on the environment and system configuration.

Which command is used to add text at any place in your file?

You can move to another position in the file and use the put command to place the text in a new position. Although you can move any block of text, this command sequence is more useful with lines than with words. The put command, p , places saved or deleted text (in the buffer) after the cursor position.

How do you string commands together in cmd?

Try using the conditional execution & or the && between each command either with a copy and paste into the cmd.exe window or in a batch file. Additionally, you can use the double pipe || symbols instead to only run the next command if the previous command failed.


1 Answers

echo "my line" > newFile.txt type myOriginalFile.txt >> newFile.txt type newFile.txt > myOriginalFile.txt 

Untested. Double >> means 'append'

like image 86
DarkwingDuck Avatar answered Sep 25 '22 12:09

DarkwingDuck