develog

[bash] split path & filename 본문

OS & Shell/bash

[bash] split path & filename

냐옴 2021. 3. 9. 16:04

 

file=aa/bb/cc/dd_ee.txt
path=`dirname "$file"`
name=`basename "$file"`

 

 

stackoverflow.com/questions/13767252/ubuntu-bash-script-how-to-split-path-by-last-slash

 

Ubuntu bash script: how to split path by last slash?

I have a file (say called list.txt) that contains relative paths to files, one path per line, i.e. something like this: foo/bar/file1 foo/bar/baz/file2 goo/file3 I need to write a bash script that

stackoverflow.com

 

Comments