curl
コマンドの出力を解析する必要があります。
curl --user test:test http://192.168.1.1/security/pkm.html | egrep '@company|config.pkm.password'
これにより、次のものが返されます。
<input type="text" id="config.pkm.dentity" name="config.pkm.identity" value="[email protected]" maxlength="64" />
<input type="text" id="config.pkm.inner_identity" name="config.pkm.inner_identity" value="[email protected]" maxlength="64" />
<input type="password" id="config.pkm.password" name="config.pkm.password" value="382738" maxlength="64" />
name="config.pkm.identity"
検索して印刷したい検索して印刷したい検索し[email protected]
てname="config.pkm.inner_identity"
印刷[email protected]
しname="config.pkm.password"
たい382738
Grep は[email protected]
、[email protected]
と382738
。のみ出力します。
ベストアンサー1
これには実際にHTMLパーサーを使用する必要がありますが(脆弱な)Awkソリューションは次のとおりです。
awk -F'"' '/pkm.identity/ {id = $8}; /inner_/ {inner = $8}; /password/ {pass = $8} END {print id" "inner" "pass}' file
[email protected] [email protected] 382738