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.
非常に巨大なテキスト ファイルがあり、変数の値が 1000 より大きい最初の行を見つける方法を知りたいです。
次のように、変数とその値の間にスペースが 1 つだけあると仮定します。
abcd 24
abcd1000 を超える最初の出現を見つけ、行番号と一致する行を出力して終了します。
abcd
$ awk '$1=="abcd" && $2>1000{print NR, $0; exit}' file
1000 より大きい変数を見つけるには、最初の条件を削除します。
$ awk '$2>1000{print NR, $0; exit}' file