linux - Replace the first word in a line with a word from the previous line -
i have text this
replace: c 1: usa - replace: sn 1: garlapati for each line starting replace: utilize next word replace first word on next line (which 1 in case):
replace: c c: usa - replace: sn sn: garlapati
this line should do:
awk -f': *' -v ofs=": " '$1=="replace"{r=$2;print;next}r{$1=r;r=""}7' file test input:
kent$ cat f replace: c 1: usa - replace: sn 1: garlapati kent$ awk -f': *' -v ofs=": " '$1=="replace"{r=$2;print;next}r{$1=r;r=""}7' f replace: c c: usa - replace: sn sn: garlapati linux shell unix awk sed
No comments:
Post a Comment