
이와 같이 bash 루프에서 경로와 파일 요소를 어떻게 분리할 수 있습니까?
for file in `find /my/path -name "*.ext"`
do
#(path,onlyfile) = separate_path_and_file $file
#dosomethingwith $onlyfile
done
답변1
당신은 할 수 없습니다. 하지만 별도로 할 수도 있습니다.
$ foo=/usr/local/bin/bar
$ echo "${foo##*/}"
bar
$ echo "${foo%/*}"
/usr/local/bin