I would like to know if have some Sed/Grep or Awk regex to parse Cisco interface section, with specific attribute, like bellow.
Content of file.txt
!
interface FastEthernet0/1
no ip unreachables
!
interface FastEthernet0/2
no ip proxy-arp
!
Script:
#!/bin/bash
VALUE="no ip proxy-arp"
awk -v RS='!\n' -v PATTERN=${VALUE} '/$PATTERN/' file.txt | awk '/^interface/';
exit 0
The problem is when I run line directly from shell, it work, but when I run from script, it don't work.
Running with bash -x
, I can see that awk
can't replace variable value.
Any suggestions ?
grep -B1 'no ip proxy-arp' file.txt | head -1
? What is the expected output? – Teresa e Junior Apr 12 at 3:16