The find -exec primary's synopsis lines from the POSIX standard are:
When entering the 1st form on a shell command line, you have to use \; instead of just ; because the semicolon has a special meaning to the shell. In the first form, if any argument is {}, it will be replaced by the currently matched pathname, and utility_name will be invoked with the modified argument(s). When using this form, some (but not all) find implementations will replace any occurrence of {} in an argument with the pathname; others only replace {} when those two characters are the only characters in the argument.
In the second form, the {} can only appear once and it must be the last argument before the -exec primary's terminating + operand. In this form, utility_name may be invoked with the given arguments and several matched pathnames. The number of pathnames that can be passed to the given utility will be limited by the system's setting for {ARG_MAX} (the maximum number of bytes that can be passed to a child process in its environment and argument lists). If you are processing a lot of files, only use the pathname a single time and as the last argument in the argument list, and the utility accepts multiple pathname operands, this form can be significantly more efficient.
Currently iam working on solaris environment,
Iam using find command to get list of all files between any two given dates. But the find command is not listing files accord. to timestamp. I tried using -exec option as -exec ls -ltr {} \;
Still the files are not listed according to timestamp..... (8 Replies)
Hi,
I want to be able to list all the names in a file which begin with a capital letter, but I don't want it to list words that begin a new sentence. Is there any way round this?
Thanks for your help. (1 Reply)
dear all
when i compile any file under solaris it gives the below warning how can i disable it
-bash-3.00$ make GNLPFT177
make: Warning: File `GNLPFT177.rc' has modification time 36 s in the future
make GNLPFT177.c
make: Entering directory `/devapp/jordev/batch/source'
make: Warning: File... (3 Replies)
Hi,
I am using HP-UX B.11.23 U ia64
I am trying to retrieve files using -mtime option of find command
However I found that -mtime is not giving correct results
Following is the output of commands executed on 03-Dec-2009
It can be seen that -mtime +1 should have returned all... (2 Replies)
Hi People,
I need some Help to write a unix script that asks for a sentence to be typed out then with the sentence. Counts the number of spaces within the sentence and then echo's out "The Number Of Spaces In The Sentence is 4" as a example
Thanks
Danielle (12 Replies)
Hi Gurues,
I need to modify an existing script that uses find to search a folder, and then move its contents to a folder. What I need to do is run gzip on each file after it's moved.
So, I ran this little test:
Put a ls.tar file on my $HOME, mkdir tmp, and then:
virtuo@tnpmprd01: find .... (3 Replies)
Hi,
i have a directory structure which contains few files each.
each file in turn has some functions. i'm searching for a word, say 'pen' in all the files present in all the directories. :wall:
consider a file file1.c in Dir1. out of the 3 funcs present in this file, func1(pennum) and... (3 Replies)
Hello,
I am running below command as root user
#nodetool cfstats tests | grep "Memtable switch count"
Memtable switch count: 12
Where as when I try to run same command as another user it gives different result.
#su -l zabbix -s /bin/bash -c "nodetool cfstats tests | grep "Memtable switch... (10 Replies)
Hello All,
May i please know how do i ensure my split command would NOT generate incomplete output files like below, the last lines in each file is missing some columns or last line is complete.
split -b 50GB File File_
File_aa
|551|70210203|xxxxxxx|12/22/2010 20:44:58|11/01/2010... (1 Reply)
In a fastload teradata utility I am trying to delete the files which are older than 30days using the find and rm command as following.
find . -name 'xxx_*' -mtime +30 -exec rm -f {} \;
I expect it to delete all the files older than 30 days but sometimes it gives an error : find: bad status--... (3 Replies)
Discussion started by: stelkar
3 Replies
LEARN ABOUT BSD
find
FIND(1) General Commands Manual FIND(1)NAME
find - find files
SYNOPSIS
find pathname-list expression
find pattern
DESCRIPTION
In the first form above, find recursively descends the directory hierarchy for each pathname in the pathname-list (i.e., one or more path-
names) seeking files that match a boolean expression written in the primaries given below. In the descriptions, the argument n is used as
a decimal integer where +n means more than n, -n means less than n and n means exactly n.
The second form rapidly searches a database for all pathnames which match pattern. Usually the database is recomputed weekly and contains
the pathnames of all files which are publicly accessible. If escaped, normal shell "globbing" characters (`*', `?', `[', and ']') may be
used in pattern, but the matching differs in that no characters (e.g. `/') have to be matched explicitly. As a special case, a simple pat-
tern containing no globbing characters is matched as though it were *pattern*; if any globbing character appears there are no implicit
globbing characters.
-name filename
True if the filename argument matches the current file name. Normal shell argument syntax may be used if escaped (watch out for
`[', `?' and `*').
-perm onum
True if the file permission flags exactly match the octal number onum (see chmod(1)). If onum is prefixed by a minus sign, more
flag bits (017777, see stat(2)) become significant and the flags are compared: (flags&onum)==onum.
-type c True if the type of the file is c, where c is b, c, d, f, l or s for block special file, character special file, directory, plain
file, symbolic link, or socket.
-links n True if the file has n links.
-user uname
True if the file belongs to the user uname (login name or numeric user ID).
-nouser True if the file belongs to a user not in the /etc/passwd database.
-group gname
True if the file belongs to group gname (group name or numeric group ID).
-nogroup True if the file belongs to a group not in the /etc/group database.
-size n True if the file is n blocks long (512 bytes per block).
-inum n True if the file has inode number n.
-atime n True if the file has been accessed in n days.
-mtime n True if the file has been modified in n days.
-exec command
True if the executed command returns a zero value as exit status. The end of the command must be punctuated by an escaped semi-
colon. A command argument `{}' is replaced by the current pathname.
-ok command
Like -exec except that the generated command is written on the standard output, then the standard input is read and the command
executed only upon response y.
-print Always true; causes the current pathname to be printed.
-ls Always true; causes current pathname to be printed together with its associated statistics. These include (respectively) inode
number, size in kilobytes (1024 bytes), protection mode, number of hard links, user, group, size in bytes, and modification time.
If the file is a special file the size field will instead contain the major and minor device numbers. If the file is a symbolic
link the pathname of the linked-to file is printed preceded by ``->''. The format is identical to that of ``ls -gilds'' (note
however that formatting is done internally, without executing the ls program).
-newer file
True if the current file has been modified more recently than the argument file.
-cpio file
Write the current file on the argument file in cpio format.
-xdev Always true; causes find not to traverse down into a file system different from the one on which current argument pathname
resides.
The primaries may be combined using the following operators (in order of decreasing precedence):
1) A parenthesized group of primaries and operators (parentheses are special to the Shell and must be escaped).
2) The negation of a primary (`!' is the unary not operator).
3) Concatenation of primaries (the and operation is implied by the juxtaposition of two primaries).
4) Alternation of primaries (`-o' is the or operator).
EXAMPLES
To find all accessible files whose pathname contains `find':
find find
To typeset all variants of manual pages for `ls':
vtroff -man `find '*man*/ls.?'`
To remove all files named `a.out' or `*.o' that have not been accessed for a week:
find / ( -name a.out -o -name '*.o' ) -atime +7 -exec rm {} ;
FILES
/etc/passwd
/etc/group
/var/db/find.codes coded pathnames database
SEE ALSO sh(1), test(1), fs(5)
Relevant paper in February, 1983 issue of ;login:.
BUGS
The first form's syntax is painful, and the second form's exact semantics is confusing and can vary from site to site.
More than one `-newer' option does not work properly.
7th Edition October 11, 1996 FIND(1)