Read last word of nth line

Hi people;

i want to read the last word of the 14th line of my file1.txt. Here is the EXACT 14th line of the file.

  250  SectorPortnum=3,AuxPortInUngo=2,PortDeviceGroup=1,PortDeviceSet=1,PorDevice=1  20                   >>> Set.

i have to get the word Set. how can i call it and also how can i assign it to a variable? the field separators are space. i donot know if you need these spaces:

before 250 there are 2 spaces.
between 250 and Sector.. there are 2 spaces.
between ...PorDevice=1 and 20 there are 2 spaces.

between 20 and >>> there are

awk 'NR==14 {print $NF}' file1.txt
# if the dot has to be removed
awk 'NR==14 {sub(/\.$/,"",$NF); print $NF}' file1.txt
1 Like

with sed..

VAR=$(sed -n '14s/.* >>* \(.*\).$/\1/p' inputfile)
1 Like

thanks for all your replies :slight_smile: