gpt4 book ai didi

linux 如何在循环函数中使用 grep 作为变量

转载 作者:太空宇宙 更新时间:2023-11-04 05:15:47 26 4
gpt4 key购买 nike

我想找到c文件中的所有函数并打印这些函数,但我不知道如何正确表达grep变量$i

find=c
for i in *; do
if [ "${i}" != "${i%.${find}}" ]
then
echo "$i"
grep "^int|^void" "${1}-${i}" | sed 's/{//g'
else
echo "unable to find any funcitions"
fi
done

最佳答案

我同意评论者的观点,他们所说的工具是 ctags,您的系统上可能已经有了它。获取函数列表:

ctags -o - yourFile.c | awk '$4=="f"{print $1}'

关于linux 如何在循环函数中使用 grep 作为变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49789205/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com