Replace empty string on particular column

Hi
I would like to replace empty string with a particluar value, any suggessions with awk ?

my input file is not delimited with any delimiters

input

 
52001073M8000000004567777
5200107     000000004567778
5200107     000000004567779
52001073M8000000004567789

Expected output
output
52001073M8000000004567777
52001073M8000000004567778
52001073M8000000004567779
52001073M8000000004567789

any tips suggessions pls (i wanted with awk since my input file size will be very big runs around 10 MB)

Can it be Perl? It can handle 10MB files just as easy as AWK:

perl -pe 's/\s+//' infile > outfile

Hi,

Try next command:

$ awk '{ if ( NF == 2 ) { $0 = $1 "3M8" $2; }; print }' infile
52001073M8000000004567777
52001073M8000000004567778
52001073M8000000004567779
52001073M8000000004567789

Regards,
Birei

awk '{ gsub( / /,"3M8");print }' yourfilename

awk '{print (NF>1?$1"3M8"$2:$0)}' file
1 Like

Shamrock

awk '{print (NF>1?$1"3M8"$2:$0)}' file

can you explain me the above piece of code ..

Actually i am encountering few other hiccups when i try to update the blank records

input file

5201007   93M999999 999999 
52010 7781     878788887878
520100 7M2    999993336630

Basically there will be spaces any were in the input file, but i will have to check(for empty string -" ") and replace the only from a particular character to a particular...

TO put it more clearly
how can i use awk if input fields are not delimited at all and replace empty string( with value)