Hi Friends,
I have file1.txt as
1|dfskfj|jdhf|478
2|wehwj|hjfk|3478
i should append to the 2nd and 3rd filed with "."
output
1|dfskfj.|jdhf.|478
2|wehwj.|hjfk.|3478
Plz help
Hi Friends,
I have file1.txt as
1|dfskfj|jdhf|478
2|wehwj|hjfk|3478
i should append to the 2nd and 3rd filed with "."
output
1|dfskfj.|jdhf.|478
2|wehwj.|hjfk.|3478
Plz help
awk -F\| 'BEGIN{OFS=FS;}{$2=$2".";$3=$3".";}1' input_file
GNU sed:
sed 's/|/.|/2g' file
Code:
awk -F\| 'BEGIN{OFS=FS;}{$2=$2".";$3=$3".";}1' input_file
Hi msabhi can you please let us know the meaning of putting 1 at the last of awk command.thanks in advance
Everything in awk has the form condition{action}
. If the condition evaluates to 1 then the action is performed. If the condition is omitted then the default condition is 1, so the action is always performed. If the action is omitted then the default action is performed, which is {print $0}
. In this case the condition is "1" so that evaluates to 1 and the action is omitted, therefore {print $0
} is performed, which is "print the entire record".