com awk
:
awk '
/^</ { old = $NF }
/^>/ { str = $4 ; gsub(/"/,"",str) ; printf "%s old:%s new:%s\n", str, old, $NF }
' your_files_list_here
Eu tenho essa saída como resultado da comparação de arquivos com diff
:
< IF-Name :STRING: "lns-wall-01-t2" Index:Gge32: 260
---
> IF-Name :STRING: "lns-wall-01-t2" Index:Gge32: 25
Eu preciso dessa saída:
lns-wall-01-t2 old:260 new:25
Eu quero usar sed.
com awk
:
awk '
/^</ { old = $NF }
/^>/ { str = $4 ; gsub(/"/,"",str) ; printf "%s old:%s new:%s\n", str, old, $NF }
' your_files_list_here
sed '
/^</{
# first line formatting
s/^.*"\(.*\)".*: / old:/
# append next 2 lines
N
N
# exchange from 2nd line begining till last ":" by "new"
s/\n---.*: / new:/
}' "$Rep_Scripts"/diff.txt
usa um tipo diferente de saída do diff:
diff -y --suppress-common-lines f1 f2
que oferece um formato mais fácil de usar:
F-Name :STRING: "lns-wall-01-t2" Index:Gge32: 260 |IF-Name :STRING: "lns-wall-01-t2" Index:Gge32: 25
e
diff -y ........ |
perl -nE '/"(.*?)".*?32:\s*(\d+).*32:\s*(\d+)/
and say "$1 old:$2 new:$3"'