carlr
October 11, 2012, 7:47pm
1
I have a file which contains data such as that shown below. How do i remove all the blcnak spaces, before, during and at the end of each line in one command?
300015, 58.0823212, 230.424728
300016, 58.2276459, 229.141602
300017, 58.7590027, 226.960846
300018, 59.7599487, 225.608902
300019, 61.1152496, 224.612473
I want the below:
300015,58.0823212,230.424728
300016,58.2276459,229.141602
300017,58.7590027,226.960846
300018,59.7599487,225.608902
300019,61.1152496,224.612473
agama
October 11, 2012, 8:01pm
2
Try:
sed 's/ //g' input-file >output-file
awk 'gsub(" ","")' input.txt > output.txt
If some line has no spaces, the awk
command will prevent that line from going to the output file.
hergp
October 12, 2012, 2:39am
5
Third approach, third tool:
tr -d ' ' <inputfile >outputfile
pamu
October 12, 2012, 2:43am
6
why not to attack on ,?
with sed..
sed 's/, /,/g' file
and with awk..
awk 'gsub(", ",",")' file
awk -F ", " '{$1=$1}1' OFS="," file
Jotne
October 12, 2012, 2:56am
7
Will not work in this case
bmk
October 12, 2012, 3:00am
8
Just now i tried with tr command it's removing the end of space each line..