Please use ***
[code][/code] tags*** around your code and data, to preserve formatting and to improve readability. Please do
not use quote tags, bolding, colors, or other fancy formatting.
Also, please explain in more detail. Do you just want to remove
all spaces in the file, or only certain ones?
The most common tool to use for manipulating files on a character level is
tr.
Code:
tr -d ' ' <infile >outfile
Quote:
i used the following command,
nawk -F\~ 'OFS=FS { gsub(" ", "", $3) }1'
but it doesnt remove if it has more than one space.
|
Your example text has "
|" as the delimiter, but your command is using "
~". Also, this will only removes spaces in field number 3. Is that what you want? Your sample text doesn't have any spaces there. Just leave the last parameter off of the gsub function to have it operate on the whole line. Finally, the first parameter can be a regex. So to remove all spaces with awk:
Code:
nawk '{ gsub( /[ ]+/ , "" ) } 1' infile >outfile