Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 4194

find is a command line utility to search for files in a directory hierarchy

28
votes
Those messages are sent to stderr, and pretty much only those messages are generally seen on that output stream. You can close it or redirect it on the command-line. $ find / -name netcdf 2>&- or … $ find / -name netcdf 2>/dev/null Also, if you are going to search the root directory (/), then it is often good to nice the process so find doesn't consume all the resources. $ nice find / -name …
answered Aug 26 '11 by Arcege
3
votes
What I believe you likely want is something more like: find . -not -name . -type d -prune -mtime +31 This will list the immediate directories in current directory older than 31 days. Adding the …
answered Jan 30 '13 by Arcege
1
vote
The easiest way that I've found to do it is to pipe into something else to generate commands, like sed, then execute the commands in sh. find . -name '*\?*.mp4' -print | sed 's/.*/"&";h;y/?/_/;x;G;s … /\n/ /;s/^/mv /' | sh -s The find is pretty self-explanatory, as is the sh. The sed command may take a little explanation: s/.*/"&"/ surrounds the input with double quotes to handle any …
answered Jun 20 '15 by Arcege
2
votes
The recursive grep will scan the entire tree and not care about directory structure. You need to traverse the structure and grep each directory individually. find /var/www -type d -print | while …
answered Nov 30 '14 by Arcege
3
votes
Using find is the 'right' way, and the only programmatic way, although there are variations: find . -type f -exec chmod ug+rw {} + # "+" may not be on all systems or find . -type f -print0 … | xargs -r0 chmod ug+rw # similar to the -exec + functionality or the slowest: find . -type f -exec chmod ug+rw {} \; # in case xargs is not installed Each of these selects a file (not directory …
answered Sep 1 '11 by Arcege
2
votes
It is a slightly long, but it is a single command-line. This looks at the contents of the files and compares them using a cryptographic hash (md5sum). find . -type f -exec md5sum {} + | sort | sed … 's/ */!/1' | awk -F\| 'BEGIN{first=1}{if($1==lastid){if(first){first=0;print lastid, lastfile}print$1, $2} else first=1; lastid=$1;lastfile=$2}' As I said, this is a little long... The find runs …
answered Nov 29 '14 by Arcege
2
votes
Building on Chris Card's answer, I myself use: find . -print0 | xargs -r0 grep -H searched_string The -print0 combined with -0 in xargs ensures that whitespace in filenames is handled properly. The … -r tells xargs to give at least one filename on the command-line. I also generally use fgrep if I want fixed strings (no regular expression), which is a little faster. Using find . -print0 | xargs …
answered Dec 5 '11 by Arcege
1
vote
I'd get rid of the grep and use awk: find $path -type f -print0 | xargs -0 awk "/$pattern/{print FILENAME,FNR}" But using grep and cut: find $path -type f -print0 | xargs -0 grep -nH "$pattern … socket when another program is supposed to be, then you might mess up that program. The find ... -print0 | xargs -0 gets around having whitespace in the filenames. It is not available on every UNIX system, but is on most. …
answered Nov 30 '11 by Arcege
3
votes
You should be using -type and not -xtype: -xtype c The same as -type unless the file is a symbolic link. For sym‐ bolic links: if the -H or -P option was specified, true if …
answered Oct 4 '11 by Arcege
58
votes
Some versions of sort have a -z option, which allows for null-terminated records. find folder1 folder2 -name "*.txt" -print0 | sort -z | xargs -r0 myCommand Additionally, you could also write a … high-level script to do it: find folder1 folder2 -name "*.txt" -print0 | python -c 'import sys; sys.stdout.write("\0".join(sorted(sys.stdin.read().split("\0"))))' | xargs -r0 myCommand Add the -r option to xargs to make sure that myCommand is called with an argument. …
answered Mar 16 '12 by Arcege
4
votes
Sounds like there is no file matching sftp_bcs_report_*.log in the starting directory on the second machine and more than one such file on the first server. For using find, patterns should always be quoted. …
answered Mar 28 '12 by Arcege
12
votes
As @hknik says, the -mtime operation on find is likely your best bet, but if you want to get all files around three months ago, then you need a bigger net: find . -type f -mtime -105 -mtime +77 … This will find the regular files in the month surrounding three months ago, between 11 and 15 weeks ago. …
answered Mar 9 '12 by Arcege
9
votes
I generally use: find . -type f -print0 | xargs -r0 du -a Xargs usually calls the command, even if there are no arguments passed; xargs du </dev/null will still be called, xargs -r du </dev/null …
answered Oct 11 '11 by Arcege
5
votes
You can use xargs to get what you want. find . -type f -print0 | sort -z | xargs -0 -n1 openssl sha512 The -n1 option tells xargs to only allow one argument to be given to the openssl command …
answered Nov 25 '12 by Arcege