Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace a blank with zero

Status
Not open for further replies.

ryanc2

MIS
Apr 18, 2003
73
US
I've got a file that looks like this:

00320 MMM RAL
00321 MMM RAL
00322 MMM 1 RAL
00323 MMM 12 RAL

I need to replace the null values in the third column (position 30) with zero so the file looks like this:

00230 MMM 0 RAL
00321 MMM 0 RAL
00322 MMM 1 RAL
00323 MMM 12 RAL

Anyone have any ideas?

Thanks
 


nawk -f pad.awk file.txt

#------------ pad.awk
NF == 3 {
printf("%-5s %-10s %-9s %s\n", $1, $2, 0, $3);
next;
}
1


vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top