Hi Friends,
Please help me to sort out this problem, I am running this in centos o/s and whenever I run this script I am getting "find: missing argument to `-exec' " but when I run the same code in the command line I didn't find any problem. I am using perl script to run this application.
Correct me if I am wrong any where.. This coding is to find the top 3 files in the filesystem with respect to size.
#!/usr/bin/perl
$get_filename=qx("find / -mmin 1 -type f -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nrk 2,2 |head -n3");
print "$get_filename \n";
Your feedback is appreciated on this
It's probably eating the backslash since perl double-quotes evaluate those. You may need to escape the escaping. You'll probably also need to escape those $ in your awk, since perl evaluates those into variables, and escape the double-quotes i the awk statement, so perl won't mistake them for its own.
I remember writing Perl like that: Line after line after line of nothing but system() and backticks. Eventually I noticed they were starting entire bourne shells just to parse one "mv a b" and was horrified -- by avoiding the shell I'd actually used eight of them consecutively :wall:
Returning much later, I rewrote some of these "perl" scripts as shell, making them much smaller, simpler, and saner.
$ wc -l dispatch.pl
49 dispatch.pl
$ wc -l dispatch.sh
25 dispatch.sh
$
1 Like