-1

I have a csv file called file.csv, which is created by dumping in a specific content of a xml file. The content of the csv file is like :

000000,gh9876547658732176,Ratboard,Legret,5428765432890898655,,
000001,98JHYTR,JHi,U,Kunal,0987 Ramnagar Fort,PO Box 0987,c/o Mary,NewJersey,Ket,Lat,54322,,X,X,V,,,,8,,
555555

First I was perplexed as to what 
 is and then i read ENTITY, which made me realize it's a carriage return. In my case , it appears at the end of the first 2 lines of the file.

I was trying to delete that grouping of characters using the command below :

tr -d '&#13' < file.csv > file1.csv

But the problem is that it does not just delete that group , but also any other occurrences of &, #, 1 , 3, 13 from every line of the file, which is undesirable.

Can any one tell me how to remove just this grouping of characters (&#13;) from the file and not any individual characters ? Any help will be greatly appreciated .

4
  • this question belongs on superuser.com
    – Vlad
    Sep 26, 2013 at 10:30
  • @user0000001 : I don't think so, it does belong here as well. I did not find anything in the FAQS telling me that, i cannot post a unix related question here . And i have been posting a lot of unix related question here for a long time and nobody told me otherwise . Sep 26, 2013 at 11:29
  • Yes, but this is a shell related question not programming.
    – Vlad
    Sep 26, 2013 at 12:21
  • @user0000001 : Well,it's not.The confusion may be because i mistagged it . You can say it's a command related question. Because, the command that's dumping the file is causing the entity to appear. Sep 26, 2013 at 12:34

3 Answers 3

1

You could try sed:

sed 's/&#13//g'
3
  • Thanks for the prompt response. In case i want to do the same to a xml file, will it work ? Sep 26, 2013 at 9:34
  • @TheDarkKnight If it contains that exact string, yes. If it contains a real CR, you need to strip \r instead.
    – cnicutar
    Sep 26, 2013 at 9:35
  • Thanks a lot, i will try this one out and let you know . Sep 26, 2013 at 9:35
1

sed will work sed -e s/",&#13;"//g

1
  • Thanks for the prompt response . Sep 26, 2013 at 9:40
0

this will help you..

sed -e 's/&#13;//g filename.csv'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.