Solved

UNIX SCRIPT HELP

Posted on 2012-04-12
3
249 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

813 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

10 Experts available now in Live!

Get 1:1 Help Now