Sponsored Content
Top Forums Shell Programming and Scripting find: missing argument to `-exec' while redirecting using find in perl Post 302582661 by ryran on Friday 16th of December 2011 06:48:41 PM
Old 12-16-2011
Quote:
Originally Posted by ramkumarselvam
Correct me if I am wrong any where.. This coding is to find the top 3 files in the filesystem with respect to size.
Code:
#!/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";

  • First thought: Why in the world is this a perl script?
  • Second thought: don't use ls -h: some files might have a suffix of M; some G (etc). No good.
  • Third thought: Why are you doing this? Whatever the reason, I think there has got to be a better way. You do not need to be searching your WHOLE filesystem every minute (I'm assuming that's what you're doing based on your find options). With the limited info you've given, I think you would be much better off installing inotify-tools (available in every major distro) and watching only the directories that things are being created in.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

Hello, I create a file touch 1201093003 fichcomp and inside a repertory (which hava a lot of files) I want to list all files created before this file : find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long but i make a filter all... (1 Reply)
Discussion started by: yacsil
1 Replies

2. UNIX for Advanced & Expert Users

find and exec

Hi, Happy new year. Would you be so kind to explain me what does this instruction : find /rep/app -type l -exec ls -l {} \;> allink.lst Many thanks. (2 Replies)
Discussion started by: big123456
2 Replies

3. UNIX for Dummies Questions & Answers

How to find the last argument in a argument line?

How to find the last argument in a argument line? (4 Replies)
Discussion started by: nehagupta2008
4 Replies

4. Shell Programming and Scripting

find: No match due to find command being argument

I am using csh and getting the error "find: No match." but I cannot figure out why. What I am trying to do is set the find command to a variable and then execute the variable as a command. I ran it through a debugger and it looks like $FIND is getting set but the find command can not actually be... (2 Replies)
Discussion started by: mst3k4l
2 Replies

5. UNIX for Dummies Questions & Answers

"-maxdepth 1" argument for Solaris find. Other way to restrict find in only one directory?

Hi I wish to find only files in dir /srv/container/content/imz06/. It means exclude subfolder /srv/container/content/imz06/archive/ > uname -a SunOS testbox6 5.10 Generic_139555-08 sun4v sparc SUNW,Sun-Blade-T6320Its Solaris default "find" > find /srv/container/content/imz06/* -name... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

6. Ubuntu

Find and EXEC

This is a huge issue. and I need it fixed ASAP. account-system gate-system race_traffic_sensor achievement-system global race_voicepack admin glue-system realdriveby admin-system gps realism-system... (5 Replies)
Discussion started by: austech360
5 Replies

7. Programming

find the missing sequence in hash perl

Dear Perl's Users, Could anyone help me how to solve my problem. I have data with details below. TTY NAME SEQUENCES U-0 UNIX 0 U-1 UNIX 1 U-2 UNIX 2 <-- From 2 jump to 5 U-5 UNIX 5 U-6 UNIX 6 <-- From 6 jump to 20 U-20 ... (2 Replies)
Discussion started by: askari
2 Replies

8. UNIX for Dummies Questions & Answers

find/xargs/*grep: find multi-line empty "try-catch" blocks - eg, missing ; not in a commented block

How can I recursively find all files in a directory and print out the file and first line number of any text blocks that match the below cases? This would seem to involve find, xargs, *grep, regex, etc. In summary, I want to find so-called empty "try-catch blocks" that do not contain code... (0 Replies)
Discussion started by: lifechamp
0 Replies

9. Shell Programming and Scripting

2 exec in find

Guys, I want to find the log files greather than 23 days and i want to perform 2 things here. one is to list the files and second is to gzip the files. hope this can be done using sh -c option. but not sure the exact command. find . -name "*.log" -mtime +23 -exec ls -la {} \; ... (5 Replies)
Discussion started by: AraR87
5 Replies

10. UNIX for Beginners Questions & Answers

Find: missing argument to `-mtime'

this find command works when using manually on the command line -- $ ls -latr file*.log -rw-r--r-- 1 oracle dba 75 Jan 4 05:00 file_2.log -rw-r--r-- 1 oracle dba 75 Jan 4 05:00 file_1.log $ $ find . ! -name -prune -type f -name "file*.log" -daystart -mtime 2 ./file_1.log ./file_2.log $... (8 Replies)
Discussion started by: wtolentino
8 Replies
get_filename(3alleg4)						  Allegro manual					     get_filename(3alleg4)

NAME
get_filename - Returns a pointer to the filename portion of a path. Allegro game programming library. SYNOPSIS
#include <allegro.h> char *get_filename(const char *path); DESCRIPTION
Finds out the filename portion of a completely specified file path. Both `' and `/' are recognized as directory separators under DOS and Windows. However, only `/' is recognized as directory separator under other platforms. Example: get_executable_name(name, sizeof(name)); allegro_message("Running `%s' ", get_filename(name)); Note that Allegro won't perform any IO operations during the verification. This means that if you have `/a/path/like/this/', which doesn't have a filename, the function will return a pointer to the trailing null character. However, if you have `/a/path/like/this', Allegro will return a pointer to `this', even if it is a valid directory. RETURN VALUE
Returns a pointer to the portion of `path' where the filename starts, or the beginning of `path' if no valid filename is found (eg. you are processing a path with backslashes under Unix). SEE ALSO
get_extension(3alleg4), put_backslash(3alleg4), replace_filename(3alleg4), exmidi(3alleg4) Allegro version 4.4.2 get_filename(3alleg4)
All times are GMT -4. The time now is 09:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy