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.
列 X の 5 行目から 5 行目 + Y の値を取得しようとしていますawk。これはどのように行われますか?
awk
私はこれがあなたのために働くと思います、テストされていません:
awk 'NR >= 5 && NR <= 5 + Y { print $X }' file.txt
明らかに、いくつかの実際の値Xを andに置き換えます。Y
X
Y
編集:
XとYがシェル変数の場合:
awk -v column="$X" -v range="$Y" 'NR >= 5 && NR <= 5 + range { print $column }' file.txt