Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
grep -F "$name" -A1000 filename | sed -n '1p;19p;24p'
上記のgreplet a=10,b=20,c=30コマンドでは、'$ap;$bp;$cp'代わりに使用でき'1p;19p;24p'ますか?
let a=10,b=20,c=30
'$ap;$bp;$cp'
'1p;19p;24p'
もう一つ、私は として与えました-A1000。これは、 1p から 1000 行までを考慮することを意味しますよね? 番号を指定せずにファイル全体を検索する必要があります。
-A1000
変数を引用符で囲みたい場合は、"代わりに'.
"
'
変数に英数字のサフィックスを追加する場合は、それが名前の一部ではないことを示す必要があります。
sed -n "${a}p;${b}p;${c}p"
または:
sed -n "$a"'p;'"$b"'p;'"$c"'p'