Is there a way I can remove any whitespace at the end of any string.
I tried sed 's/ *//g', but it removes all white space and the above string becomes like this RatrunafterCat. But i dont want the format to be changed. Plz help.
Thanks,
columna, columnb, columnc, columnd,
tom dom, rom pom[whitespace], pom pok, som pok
tok dok, ghom gok, poch gok[whitespace], zom zok
There is a single space or whitespace before the comma delimiters which is createing problems. I tried to see what it is through cat -v but was unable to get what it is. I removed it through vi editor but that's not the permanent solution. When I use sed command to remove whitespace it removes all the whitespaces there in thus making my file look like below but that space is not gone
so i need to remove the whitespace or the hidden space from column b and columnc only and that too everytime at the end of the string.
> echo "tom dom, rom pom , pom pok, som pok"
tom dom, rom pom , pom pok, som pok
> echo "tom dom, rom pom , pom pok, som pok" | sed "s/ ,/,/"
tom dom, rom pom, pom pok, som pok
Really nice of you Joeyg, But I need a permanent solution or script to attach for this flat file whereby everytime we get it we can clean it up. Sorry to bother but do u have any clues.thanks
also I tried sed "s/ ,/,/" test.csv>tes1.csv
this one stays no clue why
i tried with echo too but the space stays ...........what is it god knows?
joeyg has provided the solution for your problem ...
if you are not sure what it is
you can open file in VIM then do ":set list" make sure you are not in insert mode.
if you are still not able to make out again in vim go to the place where there is something you dont want and type "ga" which will display hex/octal value for same . use perl command to remove this hex/octal value.