Issue
I have the following string
xml_srx_name="<name>SRX-NAME</name>"
I am trying to print the text between > and < so it would print SRX-NAME
I am really close but this is what I get: >SRX-NAME< which is what I was able to achieve with this command:
$ cat $xml_srx_name | awk '/SRX-NAME/ {print $1}' | grep -oPz "(?s)>.*?<" | tr '\0' '\n'
Output:
>SRX-NAME<
Solution
You can try
- Add
| tr -d '<>'
in the end - Use
cat … |grep -o SRX-NAME
- Use
cat … |cut -d \> -f 2 | cut -d \< -f 1
Answered By - Tiago Peczenyj Answer Checked By - Terry (WPSolving Volunteer)