Hello,
I'm trying to move the last word of matching pattern to the begining of next line. Appreciate if anyone post the script.
From the below line I'm getting the last word, Note: this word also appears in many places in my file
#return the last word of line that contains ListenPort
sed -n -e 's/.*\(ListenPort="[0-9][0-9][0-9][0-9][0-9]"\)$/\1/p' test.txt
Input:
ListenAddress="xyz.com" ListenPort="11111"
Name="V1Server" NativeIOEnabled="true"
<Machine Name="xyz">
<Manager ListenAddress="" ListenPort="11113" Name="xyz"/>
</Machine>
ListenAddress="xyz.com" ListenPort="11112"
Machine="xyz" Name="V2Server"
Expected Output:
ListenAddress="xyz.com"
ListenPort="11111" Name="V1Server" NativeIOEnabled="true"
<Machine Name="xyz">
<Manager ListenAddress="" ListenPort="11113" Name="xyz"/>
</Machine>
ListenAddress="xyz.com"
ListenPort="11112" Machine="xyz" Name="V2Server"
Thanks