小编Nat*_*tal的帖子

Zsh中"${(@f)...}"的作用是什么?

我遇到了一个 Zsh 脚本,想知道它的含义。在下面的脚本中有${$(@f)$(egrep "$2","$file")}表达式。从我搜索到的,@是使用代表所有位置参数,但是f上面脚本中的任何地方都没有提到后缀字母,我找不到任何在线资料说明其特殊含义。

#!/usr/bin/env zsh

tmp_file="/tmp/_unsorted_find_n_grep"
echo "--- find <$2> in <$1>" > $tmp_file

find . -follow -iname "$1" | while read file
do
    timestamp=$(ls -l --time-style=+"%Y-%m-%d %H:%M:%S" "$file" | gawk '{print $6, $7}')
    linestack=${(@f)$(egrep "$2" "$file")}
    for line in $linestack 
do
    echo "$timestamp $file: $line" >> $tmp_file
done
done

cat $tmp_file | sort
rm $tmp_file
Run Code Online (Sandbox Code Playgroud)

zsh variable-substitution

6
推荐指数
2
解决办法
1382
查看次数

3
推荐指数
1
解决办法
6830
查看次数

标签 统计

variable-substitution ×1

wget ×1

zsh ×1