使用sed提取bash函数
Hujiuxiang
・1 分钟阅读
提取bash函数
sed -n '/^function h()/,/^}/p' script.sh
我经常需要从bash脚本中提取一个函数,这个命令会这样做。
示例输出
$ sed -n '/^function h()/,/^}/p' .bash_profile function h() { if [ -z"$1" ] then history else history | grep"$@" fi }