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.
我需要选择例如:
的特定文件并将结果放在另一个文件中。
这是我到目前为止所尝试的:
sed -n -e '7p' -e '8p' -e '11p' Old_File | awk '{printf("%s %s %s\n", $2, $3, $1);}' > New_File.
单独 awk 可以完成它:
awk 'NR==7{print $2} NR==8{print $3} NR==11{print $1, $3}' Old_file > New_file
Awk足以完成该任务:
Awk
awk ' FNR == 7 { print $2; next; } FNR == 8 { print $3; next; } FNR == 11 { print $1, $3; exit; } ' input-file