Using awk
,
how we can remove extra spaces, where it finds more than one space?
We just need to keep one space between words, as usual.
The file size is 3kb.
Asked
Active
Viewed 5,341 times
-1

Jeff Schaller
- 67,283
- 35
- 116
- 255

Nayla
- 1
1 Answers
1
Since you are not giving a kind of input sample / expected output i will make my guess:
With awk
:
$ echo "$a"
one two three four
$ echo "$a" |awk -v OFS=' ' '{$1=$1}1'
one two three four
With bash:
$ echo "$a"
one two three four
$ echo $a #mind the absence of quotes around the variable
one two three four
Also tr -s ' '
will work fine....

George Vasiliou
- 7,913
tr -s " "
4 more to go... – jesse_b Dec 26 '17 at 23:39awk '{$1=$1} 1' somefile
– steeldriver Dec 26 '17 at 23:41