Solved

Simple Awk

Posted on 2004-04-02
3
566 Views
Last Modified: 2010-04-21
Simple AWK --- I have this in a file     Apr 02   and I want this Apr 2    I want to replace the only the leading 0 with a blank, I have tried using awk sub, (0,,file) and awk substr ($2,0,1) but I can not get the blank to work. Can I just delete the leading 0? Brain dead need help. thanks  

0
Comment
Question by:petro2
  • 2
3 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 10746315
awk 'gsub(/ 0+/," ")'
0
 
LVL 84

Expert Comment

by:ozo
ID: 10746318
awk '{gsub(/ 0+/," ");print}'
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 250 total points
ID: 10746780
keep in mind that gsub is nawk, gawk

awk '{printf"%s %d",$1,$2}'
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question