Hi,
i have the log attached. Actually i want the long space just become 1 space left
like this :
Rgds,
Hi,
i have the log attached. Actually i want the long space just become 1 space left
like this :
Rgds,
Try:
while read line; do echo $line; done < file
try:
awk '$1=$1' log.txt
while read -r line
do
echo $line
done < "file"
sed 's/ */ /g' log.txt
if the file has tabs also, then
sed 's/[ \t]\+/ /g' log.txt
Puzzling ... but it works (need nawk or gawk under Solaris).
not at all. Its documented in gawk manual. $1=$1 just does a "reformat" of the fields.
It is indeed documented but puzzling anyway for anyone not aware assigning fields has the side effect of reformatting the output. Assigning a field to its own value looks otherwise useless. Thanks for sharing that trick !
It happens because multiple spaces are read into awk as a single field separator. When print $0 awk reinserts fields separators, i.e., whatever OFS is set to be: default is a single space.
tr -s " " " "
xargs -n11 <log.txt
This is true but only if a field has been overwritten.
$ echo 'a b c' | nawk '{print $0}'
a b c
$ echo 'a b c' | nawk '{$9=$9 ; print $0}'
a b c
This definitely works but is some kind of a hack as based on a side effect of an otherwise no op.