if I have a string like some/unknown/amount/of/sub/folder/file.txt
how can I get only the the file.txt
sub string, remove the front part, while the length is unknown.
thank you
EDIT: file name could be any length, and sub folders could be any levels.
$ basename "some/unknown/amount/of/sub/folder/file.txt"
file.txt
To generically extract a substring, you can use this syntax
$ hello="abcdef"
$ echo ${hello:1:3}
bcd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With