The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 06-30-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,296
All in one sed:

Code:
sed 's/^0*\(.\{9\}\).*/\1/g'

Your example works:

Code:
000000001200820060734
        ^^^^^^^^^

## If number of didigts in front changes, ie. if the last leading zero is not a prefix:
000000000200820060734
         ^^^^^^^^^

So this can go wrong and you might want to use the following, based on a fix number/position of digits:

Code:
echo "000000001200820060734"| cut -c8-17


Last edited by zaxxon; 06-30-2008 at 05:31 AM..