How can I write to the second line of a file from the command line?

Tim Brigham

I have an external program that produces an output file (largish, 20K lines possible).

I need to insert a new line between the existing line 1 and line 2. I've been looking at awk and sed - I use one liners in each fairly regularly - but I haven't been able to come up with the right switches to do this.

Kevin
awk 'NR==1{print; print "new line"} NR!=1'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I write to dmesg from command line?

How can I run a ruby file in command line from Java?

How can I shorten a file from the command line?

How can I get octal file permissions from command line?

How can I get binary file permissions from command line?

How can I parse an XML file from the command line (for GeekTool)?

How can I create a file with a specific size from a command line?

How can I initiate Nautilus file operations from the command line?

How can I print every nth line from multiple file and write it as each set of that nth line?

How can I add line breaks in an XML file from the Unix command line?

How can you write to a file from the command line without using shell output redirection?

How to write on the second line in a .txt file (java)

How to write Rspec test for running file from command line?

How can I save the second word of each line of a file into a char?

How can I read the second to last line of a text file?

how can i extract the second and third word of a line{that starts with 9} from a file where words are seperate with |?

How can I delete the 0-8th and then the second from the top line in a file [Python]

How can I print out the second word from each line of a file in powershell?

How to start to write from second line with xlwt?

Write to temp file and read from command line

How to write on the second line of a text file, ignoring the first line?

How can I split a PDF file into single pages quickly (i.e. from the Terminal command line)?

How I can I start a powershell command line from a batch file and enforce it to stay open?

How can I copy a file from my machine to another machine from command line?

how can I grep a directory and write the full line found to a file

How can I write to a specific line number in a txt file in Java

(Python) How can I write to a specific line in csv file?

VirtualBox: How can I add (mount) a ISO image file from command-line?

How can I get the resolution (width and height) for a video file from a linux command line?