Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Feb 052010
 

Remove directory name from file path

Answer:

It is easy to use basename to remove directory name from file path

E.g.

# basename /tmp/test.txt
test.txt

# basename /tmp/test.txt .txt
test

If you supply the 2nd argument, it will remove the characters if they exist in the suffix of the input filename.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>