Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Posts
    833

    Unanswered: 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...

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    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.

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •