Delete everything before last / in bash

后端 未结 4 2100
无人共我
无人共我 2021-01-04 22:48

I have many file paths in a file that look like so:

/home/rtz11/files/testfiles/547/prob547455_01

I want to use a bash script that will pri

4条回答
  •  借酒劲吻你
    2021-01-04 23:40

    One more way:

    Use the basename executable (command):

    basename /path/with/many/slashes/and/file.extension
    

    >file.extension

    basename /path/with/many/slashes/and/file.extension .extension
    

    OR

    basename -s .extension /path/with/many/slashes/and/file.extension 
    

    > file

提交回复
热议问题