The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google unix.com



AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
extract field of characters after a specific pattern - using UNIX shell script jansat HP-UX 2 05-28-2008 12:08 AM
Terminal-specific characters in password PittWolfBW Shell Programming and Scripting 5 04-07-2008 07:08 AM
How to delete specific lines at the same time zanetti321 UNIX for Advanced & Expert Users 1 03-24-2008 07:00 AM
delete files in specific directory legato Shell Programming and Scripting 2 03-29-2006 09:46 PM
tell me how many specific characters there are? kev269 Shell Programming and Scripting 7 03-17-2006 06:45 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-20-2008
masquerer masquerer is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 20
Exclamation Delete specific characters

Hi every1

Well i have a list of numbers e.g

12304
13450
01234
00123
14567

what i want is a command to check if the number is starting from 0 and then delete the 0 without doing anything else!!!!
any help wud b appreciated!!!!!!!!
  #2 (permalink)  
Old 04-20-2008
rubin's Avatar
rubin rubin is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2007
Posts: 321
Quote:
Originally Posted by masquerer View Post

... to check if the number is starting from 0 and then delete the 0 without doing anything else!!!!

Removing only the first 0:

Code:
awk '{sub(/^0/,"")}1' list
  #3 (permalink)  
Old 04-21-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
I presume you want to delete all the leading zeroes, not only the first one, right? This the solution in sed:

Code:
sed 's/^00*//' /path/to/sourcefile > /path/to/resultfile
It should be said that both the awk- and the sed-solution are easily changed to achieve the respective other conceivable goal.

I hope this helps.

bakunin
  #4 (permalink)  
Old 04-21-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
using Perl:
Code:
perl -pi -e 's/^0+//' filename
  #5 (permalink)  
Old 04-21-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Another one:

Code:
awk '{print int($0)}' file
Regards
Closed Thread

Bookmarks

Tags
perl, sed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0