How to rename multiple lines in a text file using AWK?
For instance the first and the third, from
x y z
0 1 2
q w e
to
a b c
0 1 2
g h i
The script would look like this,
#!/usr/bin/awk -f
BEGIN {}
NR==1 { ...replace... }
NR==3 { ...more replace... }
END {}
If you need to replace fixed number of lines with fixed strings, then this script should do the trick:
NR==1 { $0 = "a b c" }
NR==3 { $0 = "g h i" }
{ print }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.