LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   removing first "0" or "63" in a text file (https://www.linuxquestions.org/questions/linux-general-1/removing-first-0-or-63-in-a-text-file-462534/)

tmaxx 07-10-2006 03:15 AM

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

tmaxx 07-10-2006 03:22 AM

or an awk solution would be great also

faref 07-10-2006 06:39 AM

vim file.txt
:%s/^0//
:%s/^63//
:wq

spirit receiver 07-10-2006 06:45 AM

Code:

sed 's/^\(0\|63\)//' filename

homey 07-10-2006 06:53 AM

Yet another way of doing that.... :)
Code:

sed -e "s/^[0,63]*//g" file.txt

spirit receiver 07-10-2006 08:08 AM

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



All times are GMT -5. The time now is 07:40 AM.