awk usage in perl scripting -


hi writing script need grep 6th column of output using awk command getting other output. exact syntax in perl extract 6th column using awk?

#!/usr/bin/perl use strict; use warnings; use diagnostics; $filesystem=`df -h |grep -i dev|grep -ve '^filesystem|proc|none|udev|tmpfs'`; print "(\"$filesystem\"|awk '{print \$6}')"  output : 7831c1c4be8c% ./test.pl ("/dev/disk1     112gi   43gi   69gi    39% 11227595 18084674   38%   / devfs          183ki  183ki    0bi   100%      634        0  100%   /dev "|awk '{print  $6}')%                                                                                

am trying remove % how can done ?

7831c1c4be8c% cat test.pl #!/usr/bin/perl use warnings; use strict;  open $fs, q(df -h |) or die $!; while (<$fs>) { print +(split)[4], "\n"     if /dev/i , not /devfs/;  }  7831c1c4be8c% ./test.pl  40% 

you don't need awk inside perl.

#!/usr/bin/perl use warnings; use strict;  open $fs, '-|', q(df -h) or die $!; while (<$fs>) {     print +(split)[5], "\n"         if /dev/i , not /^filesystem|proc|none|udev|tmpfs/; } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -