假设我*.txt在目录中有一个文件txtpath=/path/to/txt/。
*.txt
txtpath=/path/to/txt/
我想列出*.txt文件$txtpath从当前目录(不$txtpath)也没有列出当前目录下的文件,因为如果我执行情况ls *.txt $txtpath。
$txtpath
ls *.txt $txtpath
我设法*.txt仅$txtpath使用此命令列出文件:find $txtpath -name '*.txt' | sed 's/\// /g' | grep -o '[^ ]*$'
find $txtpath -name '*.txt' | sed 's/\// /g' | grep -o '[^ ]*$'
但也许有更优雅的解决方案?
ls grep sed find
find ×1
grep ×1
ls ×1
sed ×1