Re: Cut patten between slashes
From: Chris F.A. Johnson (c.fa.johnson_at_rogers.com)
Date: 05/22/04
- Next message: Heiner Steven: "Top 10 posters comp.unix.questions"
- Previous message: Charles Demas: "Re: Cut patten between slashes"
- In reply to: Wyatt: "Cut patten between slashes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 22 May 2004 20:00:37 GMT
On 2004-05-22, Wyatt wrote:
> I have a file listed as
>
> /dir1/sd11/sd111/sd1111/file1
> /d2/sd2/file2
> /d3/sd31/sd34/sd345/sd3456/sd34567/file3
>
> I want to extract only filenames from this and write them into another file
>
> file1
> file2
> file3
>
> How do I do this ? Anyhelp is appreciated.
awk -F/ '{print $NF}' FILE
Or:
sed 's|^.*/||' FILE
Or:
while read path
do
echo ${path##*/}
done < FILE
--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
===================================================================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Next message: Heiner Steven: "Top 10 posters comp.unix.questions"
- Previous message: Charles Demas: "Re: Cut patten between slashes"
- In reply to: Wyatt: "Cut patten between slashes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|