Solved

UNIX SCRIPT HELP

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what is a good general partitioning scheme for RHEL? 23 149
Wrap Oraccle SQL*Plus executable Command 4 104
SSH to Solaris server (which uses NIS) 1 47
how to send mail in unix 2 46
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.
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

738 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