LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Remove the first comma in a TXT fil (https://www.linuxquestions.org/questions/linux-newbie-8/remove-the-first-comma-in-a-txt-fil-931998/)

betsy1181 02-29-2012 02:42 PM

Remove the first comma in a TXT fil
 
I would like to remove the first comma in a text file. My file is comma delimited data so i want to be sure that i only strip the first comma and no other ones. Can you please help me?

Dark_Helmet 02-29-2012 02:46 PM

To remove the first comma in every line within the file (and not simply the first comma in the file as a whole):

Code:

sed -i.backup 's@,@@' filename
This will modify the file directly, but store an unmodified, backup copy of the file as filename.backup.

betsy1181 02-29-2012 02:57 PM

Thank you for your help, but I was not clear. I would like to be able to remove ONLY the first comma in the file.

Dark_Helmet 02-29-2012 03:04 PM

If the first comma is on line 1:
Code:

sed -i.backup '1 s@,@@' filename
If the first comma is on another line, change the number as appropriate.


All times are GMT -5. The time now is 05:02 AM.