Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

UNIX SCRIPT HELP

Posted on 2012-04-12
3
Medium Priority
?
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 26

Accepted Solution

by:
pony10us earned 2000 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 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 37840163
As a command:

sed "s/^0*//" file

Or in a script:

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
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 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…
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.
Suggested Courses

596 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