0

The following perl syntax will print the line in case line was ended with "DUPLEX"

But Sometimes DUPLEX have one space or more as

   "DUPLEX    " 

so in this case line will not printed

Please advice what I need to add in my perl syntax in order to print the line that ended with the word - DUPLEX

in spite there are some spaces after the word "DUPLEX"

perl -ne "print if /DUPLEX$/" file

.

more file

VAL=18327 FULL DUPLEX
VAL=782      HALF
1

Just look for 0 or more spaces:

perl -ne "print if /DUPLEX\s*$/" file

In the Perl regular expression language, \s matches any whitespace character and * means 0 or more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy