Results 1 to 4 of 4
Hi Guys,
I have an application that requires a data file to load and I must use sed to modify the file accordingly.
The problem is that each line in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-22-2011 #1Just Joined!
- Join Date
- Nov 2011
- Posts
- 2
Sed Basics..
Hi Guys,
I have an application that requires a data file to load and I must use sed to modify the file accordingly.
The problem is that each line in the config file is missing a comma at the end!
So I've tried
But for some reason this adds the comma at the start of the file. Well... last time I checked, '$' meant end of the line! right??Code:sed 's/$/,/' configLines
Let me know if there's another way to accomplish this or maybe my sed command is wrong.
Any help would be appreciated.
Thanks
- 11-22-2011 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,695
Hey,
Your code works fine for me.
Code:# cat ./testfile.txt a b c d e 1 2 3 4 5 # sed -i.bak 's/$/,/' ./testfile.txt # cat ./testfile.txt a b c d e, 1 2 3 4 5, #
...can you post your configLines file if the problem is there?
- 11-22-2011 #3Just Joined!
- Join Date
- Nov 2011
- Posts
- 2
Okay thank you!!
So I figure it must be my datafile! I think its worth noting that I copied the file over from win 7 -> Linux so maybe its not valid because of this?
Interesting, I opened the file and the first record starts with 'ÿþ' whatever that is... I think the data must be corrupt.Last edited by EricTheRed; 11-22-2011 at 10:34 PM.
- 11-23-2011 #4Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,695
Maybe there are carriage returns in there, thanks to Windows?
You can see them with:
If there, you will see ^M at the end of each line.Code:cat -v file.txt
You can remove them with:
Code:dos2unix file.txt


Reply With Quote
