grep
ファイルから2 行のパターンを試してhtml
、 を使用して印刷しcat
ます。行は次のとおりです。
<link type="text/css" rel="stylesheet" href="https://test.mydomain.com/store.css">
と
<script type="text/javascript" language="javascript" src="https://test.mydomain.com/store/gwt.nocache.js">
コマンドを使用してそれらを別々に使用する場合grep
。お気に入り
if grep -F -i -n '<link type="text/css" rel="stylesheet" href="https://test.mydomain.com/store.css">' tmp.html > out.txt; then cat out.txt # IT WORKS.
しかし、私はgrep
両方のパターンが必要です。で試しましたegrep
。なので
egrep '(pattern1|pattern2)'
なので
if egrep -e -i -c '(\<link type\=\"text\/css\" rel\=\"stylesheet\" href\=\"https\:\//test\.mydomain\.com\/gwtstore\/store\.css\"\>|\<link type\=\"text\/css\" rel\=\"stylesheet\" href\=\"https\:\//test\.mydomain\.com\/store\/gwt\.nocache\.js\"\>)' tmp.html > out.txt; then cat out.txt
しかし、上記の構文はうまくいきません..助けてください。コマンドを使用して別のパターンに置き換えて終了すると、ファイル内の 2 つのセットの html コードを検索しようとしますsed
。