Removing the first character of a text file

Removing the first character of a text file

Post by Bill Sample » Fri, 30 Jan 1998 04:00:00



Hello everyone,

   This is my first posting to this group so bear with me. I have a text
file such as this:
|CG12345|0.00|SIX|15.00|

Each field is delimited by the "|" (pipe) symbol. What I need to do is
to remove the FIRST pipe symbol from each line of this file. Is there a
way in awk, perl, shell, etc.

I would greatly appreciate any help.

Thanx,
--

Bill Sampler
Programmer/Analyst
IS Dept.
Redneck Trailer Supplies

...Aside from that, how did you enjoy the play Mrs. Lincoln?

 
 
 

Removing the first character of a text file

Post by Mario Starga » Fri, 30 Jan 1998 04:00:00


On Thu, 29 Jan 1998 11:36:46 -0600, Bill Sampler

thousands of dollars to say:

>Hello everyone,

>   This is my first posting to this group so bear with me. I have a text
>file such as this:
>|CG12345|0.00|SIX|15.00|

>Each field is delimited by the "|" (pipe) symbol. What I need to do is
>to remove the FIRST pipe symbol from each line of this file. Is there a
>way in awk, perl, shell, etc.

>I would greatly appreciate any help.

>Thanx,
>--

>Bill Sampler
>Programmer/Analyst
>IS Dept.
>Redneck Trailer Supplies

>...Aside from that, how did you enjoy the play Mrs. Lincoln?

        sed 's/\|//' file > file.new

--
Mario Stargard, Systems Admin   |  "Security for an OPEN World"
Product Development Group       |  Network security solutions for
SAGUS Security Incorporated     |   the enterprise.
(613) 234 7300 x214             |  http://www.sagus-security.com

 
 
 

Removing the first character of a text file

Post by Dmitry Tkac » Fri, 30 Jan 1998 04:00:00


Try this:

cat <your_file> | cut -d'|' -f2-

Hope, it helps...

Dima.

> Hello everyone,

>    This is my first posting to this group so bear with me. I have a text
> file such as this:
> |CG12345|0.00|SIX|15.00|

> Each field is delimited by the "|" (pipe) symbol. What I need to do is
> to remove the FIRST pipe symbol from each line of this file. Is there a
> way in awk, perl, shell, etc.

> I would greatly appreciate any help.

> Thanx,
> --

> Bill Sampler
> Programmer/Analyst
> IS Dept.
> Redneck Trailer Supplies

> ...Aside from that, how did you enjoy the play Mrs. Lincoln?

 
 
 

Removing the first character of a text file

Post by Rich K » Fri, 30 Jan 1998 04:00:00




>On Thu, 29 Jan 1998 11:36:46 -0600, Bill Sampler

>thousands of dollars to say:

>>Hello everyone,

>>   This is my first posting to this group so bear with me. I have a text
>>file such as this:
>>|CG12345|0.00|SIX|15.00|

>>Each field is delimited by the "|" (pipe) symbol. What I need to do is
>>to remove the FIRST pipe symbol from each line of this file. Is there a
>>way in awk, perl, shell, etc.

>>I would greatly appreciate any help.

>>Thanx,
>>--

>>Bill Sampler
>>Programmer/Analyst
>>IS Dept.
>>Redneck Trailer Supplies

>>...Aside from that, how did you enjoy the play Mrs. Lincoln?
>    sed 's/\|//' file > file.new

           ^^
                   shouldn't it be ^/| in case of computer gitch and
                   doesn't record the first |?

                   richk

- Show quoted text -

Quote:

>--
>Mario Stargard, Systems Admin   |  "Security for an OPEN World"
>Product Development Group       |  Network security solutions for
>SAGUS Security Incorporated     |   the enterprise.
>(613) 234 7300 x214             |  http://www.sagus-security.com

 
 
 

Removing the first character of a text file

Post by Kuntal M. Daftar » Sat, 31 Jan 1998 04:00:00



> This is my first posting to this group so bear with me. I have a text
> file such as this:
> |CG12345|0.00|SIX|15.00|

> Each field is delimited by the "|" (pipe) symbol. What I need to do is
> to remove the FIRST pipe symbol from each line of this file. Is there a
> way in awk, perl, shell, etc.

give this a try.

perl -pi.bak -e 's/^.(.*)$/$1/;' <filename>

---
Kuntal Daftary
1.408.527.9789

 
 
 

Removing the first character of a text file

Post by Shawn D. McPee » Sat, 31 Jan 1998 04:00:00


:> Try this:

:> cat <your_file> | cut -d'|' -f2-

I'd like to nominate this for the Useless Use of Cat Award for this week.

Shawn

--
Yow!  It's some people inside the wall!  This is better than mopping!
                                -- Zippy the Pinhead

 
 
 

Removing the first character of a text file

Post by M.A. Po » Sat, 31 Jan 1998 04:00:00



> On Thu, 29 Jan 1998 11:36:46 -0600, Bill Sampler

> thousands of dollars to say:
> >   This is my first posting to this group so bear with me. I have a text
> >file such as this:
> >|CG12345|0.00|SIX|15.00|
> >Each field is delimited by the "|" (pipe) symbol. What I need to do is
> >to remove the FIRST pipe symbol from each line of this file. Is there a
> >way in awk, perl, shell, etc.
>    sed 's/\|//' file > file.new

The | is not a reserved character.

sed -e 's/|//' file [ > new.file ]

If there is a chance that a line will not begin with |, then

sed -e 's/^|//' file  should be used to avoid the possibility of
removing one of the embedded symbols.

mp

--
 +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+  
 | sheep, n.  A stupid woolly creature, meant to be fleeced; a dupe;   |
 | an individual who uses 'no-spam' headers in UseNet newsgroups.      |
 +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
 | Linux 2.0.32 -> AMD 5x86-133  | pgpk -a finger://teleport.com/looie |
 +=-=-=-=-=+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+

 +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+

 
 
 

Removing the first character of a text file

Post by Al A » Mon, 02 Feb 1998 04:00:00


                sed "s/.//" inputfile > outputfile
--
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, seders moderator                                      sed u soon
               it is not zat we do not see the  s o l u t i o n          
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+