Append text at end of the first line in a file

Hi

I need to append some text @ end of the first line in a file.
like
myfile.txt
list = a,b,c
list.a=some..

I give the arg "d" . now it append at end of first line
list=a,b,c,d
list.a=some...

Please help me out this

awk ' NR == 1 { print $0,"sometext" } else { print }' filename

Hi madhan

Thanks , when i did this.It will print on the console.But what i need is it changed on the fie.

This is the same question you've asked here:

http://www.unix.com/shell-programming-scripting/63123-removing-specific-lines.html\#post\_message_302190543

Regards

As said by Frank :slight_smile:

use a temporary file and rename it

or do an in-place edit using sed

Hi Madhan

Thanks for the help
I found the soln

awk '{if(NR==1){print $0,"sometext"}else{print }}' output_filename > somu

My bad :frowning:

It ran off like that.

Thanks for correcting it :slight_smile:

after you redirect; rename it

mv somu output_filename

Thanks yar