how do I chop of characters at the end of a line...

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Entelin
Date:  
Subject: how do I chop of characters at the end of a line...
lol thanks everyone, sorry for not specifying the language (bash), but
suffice to say I have serveral methods now I can try :)

Thanks.

On Mon, 2003-03-03 at 22:35, Garrett E wrote:
> VAR="original.txt"
> CHOPPPED=`echo -n $VAR | perl -ne 'print substr($_, 0, -4)'`
>
> $CHOPPED is now "original".
>
> Note that echoing it without the -n will add a linefeed on the end and you
> will need to go back 5 spaces rather than 4 to achieve the desired effect.
>
> Garrett
>
> ----- Original Message -----
> From: "Bart Garst" <>
> To: <>
> Sent: Monday, March 03, 2003 9:47 PM
> Subject: RE: how do I chop of characters at the end of a line...
>
>
> > With Perl:
> >
> > #!/usr/bin/perl -w
> > $filename = shift;
> > $filename =~ s/\.\S*//;
> > print "$filename\n";
> >
> > Bart
> >
> > -----Original Message-----
> > From:
> > [mailto:plug-discuss-admin@lists.plug.phoenix.az.us]On Behalf Of Entelin
> > Sent: Monday, March 03, 2003 9:39 PM
> > To: Phoenix Linux Users Group
> > Subject: how do I chop of characters at the end of a line...
> >
> >
> > I want to take a variable say a="string.txt" and chop off the last 4
> > characters so I can make variable b equal to just "string"
> >
> > Thanks for your help
> >
> > ---------------------------------------------------
> > PLUG-discuss mailing list -
> > To subscribe, unsubscribe, or to change you mail settings:
> > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> >
> > ---------------------------------------------------
> > PLUG-discuss mailing list -
> > To subscribe, unsubscribe, or to change you mail settings:
> > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> >
>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss