If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > delete parts of rows & keeping the rows trail

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-26-04, 01:45
osy45 osy45 is offline
Registered User
 
Join Date: Nov 2002
Posts: 833
delete parts of rows & keeping the rows trail

hi,

which vi or whatever command deletes the leading parts of row in a file leaving the tail ?
I have some directory entries in the file and want to extract the filenames only...
something like this
/opt/data/archive/arch_01.dbf
/opt/data1/db21/temp.dbf
/opt/data/archive/old/arch_01.dbf
and the result should be like this
arch_01.dbf
temp.dbf
arch_01.dbf

any help highly appreciated...
Reply With Quote
  #2 (permalink)  
Old 03-26-04, 01:59
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
You can do :
Code:
sed 's!.*/!!' input_file > work_file
mv work_file input_file

# or in one shot

perl -p -i -e 's!.*/!!' input_file
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 03-26-04, 03:55
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
Re: delete parts of rows & keeping the rows trail

...or use basename
Code:
while read line
do
   echo $(basename $line)
done < file > newFile
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On