Reputation: 93
I have text file,
Input file:
sno|name|lab|result|dep
1|aaa|ALB|<= 3.67|CHE
2|bbb|WBC|> 7.2|FVC
3|ccc|RBC|> 14|CHE
Output file:
sno|name|lab|result|dep
1|aaa|ALB|<=3.67|CHE
2|bbb|WBC|>7.2|FVC
3|ccc|RBC|>14|CHE
How to remove white spaces in column 4(result)?
Upvotes: 0
Views: 974
Reputation: 66415
If you can remove spaces from everything, just use sed
:
sed 's/ //g' input.txt > output.txt
Or even tr
(translate):
tr -d ' ' < input.txt > output.txt
Otherwise, if you need to edit just the fourth column, use awk
. The following command considers |
as field separator (-F \|
) and then outputs files using |
as output field separator (-vOFS=\|
).
awk -F \| -vOFS=\| '{gsub(/ /, "", $4); print; }' input.txt > output.txt
Upvotes: 1