LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-10-2006, 04:15 AM   #1
tmaxx
LQ Newbie
 
Registered: Jun 2006
Posts: 21

Rep: Reputation: 15
removing first "0" or "63" in a text file


hi all..hope u guys can help me with this.

problem is a file containing the follwing


09195674567
09195674667
09195674767
09195674568
09195674561
09195674562
09195674563
639197896334
639197896335
639197896336
639197896337

i wanna remove the leading zeros and leading "63" using sed?

pls help
 
Old 07-10-2006, 04:22 AM   #2
tmaxx
LQ Newbie
 
Registered: Jun 2006
Posts: 21

Original Poster
Rep: Reputation: 15
or an awk solution would be great also
 
Old 07-10-2006, 07:39 AM   #3
faref
LQ Newbie
 
Registered: Jan 2004
Distribution: Slackware, Ubuntu
Posts: 25

Rep: Reputation: 15
vim file.txt
:%s/^0//
:%s/^63//
:wq
 
Old 07-10-2006, 07:45 AM   #4
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Code:
sed 's/^\(0\|63\)//' filename
 
Old 07-10-2006, 07:53 AM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Yet another way of doing that....
Code:
sed -e "s/^[0,63]*//g" file.txt
 
Old 07-10-2006, 09:08 AM   #6
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Quote:
Originally Posted by homey
Yet another way of [not] doing that....
Indeed, that would be pretty dangerous, even if it works with the example data given above.
Code:
> echo "636603661" | sed -e "s/^[0,63]*//g"
1
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 12:26 PM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 04:07 PM
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 02:34 PM
Removing "shutdown" and "reboot" in logout window nearfar Red Hat 1 10-07-2003 12:33 PM
Can't locate object method "splitpath" via package "File::Spec" RobJohnston Linux - General 2 06-28-2003 10:59 AM


All times are GMT -5. The time now is 03:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration