How do I extract a file/folder_name only from a path?

后端 未结 2 1294
醉话见心
醉话见心 2021-01-12 13:10

Unfortunately I suck at regexp. If I have a path like so:

/long/path/to/file, I just need to extact file.

If someone supplies

2条回答
  •  囚心锁ツ
    2021-01-12 13:59

    If I understand correctly, you could use the basename function.

    f <- "/long/path/to/file"
    basename(f)
    # [1] "file"
    

提交回复
热议问题