Solved

UNIX SCRIPT HELP

Posted on 2012-04-12
3
237 Views
Last Modified: 2012-04-12
I have a file which has the following data
022D0
00709
00701
006F9
006F1
022CF
022CE
022D1
00846
0068A

How do I write a script do that the 0's are removed from each row, So when I input the above file the output should looks like

22D0
709
701
6F9
6F1
22CF
22CE
22D1
846
68A
0
Comment
Question by:mnis2008
3 Comments
 
LVL 26

Accepted Solution

by:
pony10us earned 500 total points
ID: 37839768
Well there are several ways.  Rather than re-inventing the wheel take a look at this site for many of them:  

http://unstableme.blogspot.com/2010/04/remove-leading-zero-from-line-awk-sed.html

My personal favorite is using vi

:1,$ s/^[0]*//


That is what I am used to.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 37839791
sed 's/^0\{1,\}//' lunids
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 37840163
As a command:

sed "s/^0*//" file

Or in a script:

sed "s/^0*//" $1
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
prtdiag report hdd failure 10 126
nodeip 9 68
AIX 5.x set up arrow to recall 11 42
Remote Change Dates on AIX Automation 7 43
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now