Find the answer to your Linux question:
Results 1 to 2 of 2
I have a txt file containing names of files, but they have the address appended to them, which I don't want. eg. /path1/file1.dat /path2/file2.dat etc. what is the easiest way ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2010
    Posts
    5

    removing path prefix from filesnames


    I have a txt file containing names of files, but they have the address appended to them, which I don't want.

    eg.

    /path1/file1.dat
    /path2/file2.dat
    etc.

    what is the easiest way to remove the path from all the filenames in the last?
    I don't think that "basename" would be very easy to implement is it only takes on operand at a time.

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,439
    Code:
     awk -F "/" '{print $NF}' textfile
    You must always face the curtain with a bow.

Posting Permissions

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