You can actually remove the cut step altogether:
erik@kim:~> while read FILE; do basename $FILE .extention; done <
testfile
foo
bar
x
erik@kim:~> cat testfile
/some/dir/foo.extention
/some/dir/bar.extention
/some/dir/x.extention
erik@kim:~>
basename will remove the file extention if you tell it what the
extention is; ".extention" in this case.
>>> george@georgetoft.com 03/03/04 1:05 PM >>>
Kyle Faber wrote:
>
> Howdy,
>
> I have a real quick need for a dirty bash script which I don't
forsee using
> for long. I apologize for not doing any research, but I need to
quickly know
> how to do the following and I figured one of the gurus here could help
me out
> in the short term, so I can learn all about this later...
>
> I have a text file filled with entires of the following.
>
> /some/dir/foo.extension
> /some/dir/bar.extension
> /some/dir/x.extension
> etc.
>
> I would like to parse the file and generate a new text file that looks
like
> this:
>
> foo
> bar
> x
> etc.
>
> The directories and the extensions are all the same.
>
> Oh and if it matters:
>
> [zoom@godzilla zoom]$ /bin/bash -version
> GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu)
>
> Thanks a TON!!!
> --
> Kyle Faber
> Account Manager
> EMR Internet
> kyle@emr.net
> 623-581-0842 voice
> 623-582-9499 fax
>
> UNIX is a registered trademark of The Open Group in the United States
and
> other countries.
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
Since I'm bored . . .
bob@donelle:/tmp> while read FILE; do basename $FILE | cut -f1 -d.; done
< testfile
foo
bar
x
bob@donelle:/tmp> cat testfile
/some/dir/foo.extension
/some/dir/bar.extension
/some/dir/x.extension
bob@donelle:/tmp>
--
George Toft
CISSP, NCNI/NSNS, MSIS
Computer Security
AGD,llc
www.agdllc.com
623-203-1760
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss