这与这个问题类似,但我想在Unix中包括相对于当前目录的路径。如果我执行以下操作:
ls -LR | grep .txt
它不包括完整路径。例如,我有以下目录结构:
test1/file.txt
test2/file1.txt
test2/file2.txt
上述代码将返回:
file.txt
file1.txt
file2.txt
如何使用标准Unix命令,使它包含相对于当前目录的路径?
这与这个问题类似,但我想在Unix中包括相对于当前目录的路径。如果我执行以下操作:
ls -LR | grep .txt
它不包括完整路径。例如,我有以下目录结构:
test1/file.txt
test2/file1.txt
test2/file2.txt
上述代码将返回:
file.txt
file1.txt
file2.txt
如何使用标准Unix命令,使它包含相对于当前目录的路径?
.zshrc
或 .bashrc
文件中:filepath() {
echo $PWD/$1
}
filepath2() {
for i in $@; do
echo $PWD/$i
done
}
第一个显然只适用于单个文件。
sed "s|<OLDPATH>|<NEWPATH>|g" input_file > output_file
tree -ifF ./dir | grep -v '^./dir$' | grep -v '.*/$' | grep '\./.*' | while read file; do
echo $file
done
绝对路径
tree -ifF ./dir | grep -v '^./dir$' | grep -v '.*/$' | grep '\./.*' | while read file; do
echo $file | sed -e "s|^.|$PWD|g"
done
file***.txt
。ls /some/path/here | find . -name 'file*.txt' (* represents some wild card search)