Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove first character from first line using sed

I have three .csv files that are output from saving a query in MS SQLServer. I need to load these files into an Informix database, which requires that tacking on of a trailing delimiter. That's easy to do using sed

s/$/,/g

However, each of these files also contains (as displayed by vim, but not ed or sed) an at the first character position of the first line.

I need to get rid of this character. It deletes as one character using vim's x command. How can I describe this character using sed so I can delete it without removing the line.

I've tried 1s/^.//g, but that is not working.

like image 761
octopusgrabbus Avatar asked Dec 18 '12 15:12

octopusgrabbus


2 Answers

Try this instead:

sed -e '1s/^.//' input_file > output_file

Or if you'd like to edit the files in-place:

sed -ie '1s/^.//' input_file

(Edited) Apparently s/^.// doesn't quote do it, updated.

like image 150
sampson-chen Avatar answered Sep 25 '22 11:09

sampson-chen


Remove the first character on the first line inplace:

sed -i  '1s/^.//' file
like image 37
Chris Seymour Avatar answered Sep 24 '22 11:09

Chris Seymour