Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
2 deleted 170 characters in body
source | link

I tried below 3 methods by using sed, awk and python

sed command

    I tried  below 3 methods by using sed, awk and python

    sed command

    echo "pass2: <Marvell Console 1.01> Removable Processor SCSI device" | sed "s/.*<//g"|sed "s/>.*//g"

    output

    

output

Marvell Console 1.01
 
    awk command

    

awk command

echo "pass2: <Marvell Console 1.01> Removable Processor SCSI device" | awk -F "[<>]" '{print $2}'
 
    output
    

output

Marvell Console 1.01

    python

        

python

#!/usr/bin/python
        import re
        h=[]
        k=open('l.txt','r')
        l=k.readlines()
        for i in l:
            o=i.split(' ')
            for i in o[1:4]:
                h.append(i)
        print (" ".join(h)).replace('>','').replace('<','')

 
output

output

Marvell Console 1.01
    I tried  below 3 methods by using sed, awk and python

    sed command

    echo "pass2: <Marvell Console 1.01> Removable Processor SCSI device" | sed "s/.*<//g"|sed "s/>.*//g"

    output

    Marvell Console 1.01
 
    awk command

    echo "pass2: <Marvell Console 1.01> Removable Processor SCSI device" | awk -F "[<>]" '{print $2}'
 
    output
    Marvell Console 1.01

    python

        #!/usr/bin/python
        import re
        h=[]
        k=open('l.txt','r')
        l=k.readlines()
        for i in l:
            o=i.split(' ')
            for i in o[1:4]:
                h.append(i)
        print (" ".join(h)).replace('>','').replace('<','')

 
output

Marvell Console 1.01

I tried below 3 methods by using sed, awk and python

sed command

echo "pass2: <Marvell Console 1.01> Removable Processor SCSI device" | sed "s/.*<//g"|sed "s/>.*//g"

output

Marvell Console 1.01

awk command

echo "pass2: <Marvell Console 1.01> Removable Processor SCSI device" | awk -F "[<>]" '{print $2}'

output

Marvell Console 1.01

python

#!/usr/bin/python
import re
h=[]
k=open('l.txt','r')
l=k.readlines()
for i in l:
    o=i.split(' ')
    for i in o[1:4]:
        h.append(i)
print (" ".join(h)).replace('>','').replace('<','')

output

Marvell Console 1.01
1
source | link

    I tried  below 3 methods by using sed, awk and python

    sed command

    echo "pass2: <Marvell Console 1.01> Removable Processor SCSI device" | sed "s/.*<//g"|sed "s/>.*//g"

    output

    Marvell Console 1.01

    awk command

    echo "pass2: <Marvell Console 1.01> Removable Processor SCSI device" | awk -F "[<>]" '{print $2}'

    output
    Marvell Console 1.01

    python

        #!/usr/bin/python
        import re
        h=[]
        k=open('l.txt','r')
        l=k.readlines()
        for i in l:
            o=i.split(' ')
            for i in o[1:4]:
                h.append(i)
        print (" ".join(h)).replace('>','').replace('<','')


output

Marvell Console 1.01