我的命令是:
[root@my /]# grep -lr --include=*version.php "$wp_version"/home/draka/www/
/home/draka/www/wp-content/version.php
/home/draka/www/wp-content/themes/version.php
/home/draka/www/wp-includes/version.php
我使用sed找到特定的行:
[root@my /]# grep -lr --include=*version.php "$wp_version" /home/draka/www/ | xargs sed -n '7p'
$wp_version = '3.5';
每个文件夹的文件版本都不同:
我的问题是,我如何结合这两个输出?我想要的输出可能是这样的:
/home/draka/www/wp-content/version.php = $wp_version = '3.5.1';
或
/home/draka/www/wp-content/version.php -> $wp_version = '3.5.1';
非常感谢您的及时回复。谢谢。
答案 0 :(得分:1)
省略-l
,就像grep -r --include=*version.php wp_version /home/draka/www/
一样,会这样做。另见 man grep :
-H, --with-filename Print the file name for each match. This is the default when there is more than one file to search.