Get last field using awk substr

前端 未结 8 527
天涯浪人
天涯浪人 2020-11-29 02:20

I am trying to use awk to get the name of a file given the absolute path to the file.
For example, when given the input path /home/parent/child/filena

8条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 02:54

    Like 5 years late, I know, thanks for all the proposals, I used to do this the following way:

    $ echo /home/parent/child1/child2/filename | rev | cut -d '/' -f1 | rev
    filename
    

    Glad to notice there are better manners

提交回复
热议问题