Tagged Questions
1
vote
4answers
482 views
Checking if a file exists in several directories
I've been working on this far too long and need some help.
I need a script that will look at files in a directory and see if it exists in one of several directories.
I need something like this:
for ...
4
votes
2answers
128 views
Dealing with script interruption
I need to iterate over between 120k and 500k files. find handles this well.
find $PWD -type f -path "fragments/*.pdbqt"
For some reason I want to list the same set of files again, in the same ...
5
votes
4answers
3k views
How can I use bash's if test and find commands together?
I have a directory with crash logs, and I'd like to use a conditional statement in a bash script based on a find command.
The log files are stored in this format:
/var/log/crashes/app-2012-08-28.log
...
2
votes
4answers
433 views
chown all files based on file name pattern in current directory
I'm trying to chown all files whose filenames begin with ChownFileNames. I've used this command, but it doesnt seem to work:
find . -maxdepth 1 |grep 'ChownFileNames*' -exec chown hadoop:hadoop -- {} ...
6
votes
2answers
460 views
sync files recursively between two folders where files are less than 24 hours old
I want to find all the files under a directory which are within 24 hours then rsync those files with another server.
There are some old files that I do not want to transfer, however if those old ...
2
votes
2answers
433 views
Ignoring files that find cannnot search or open?
I searched for big files using this command on HP Unix:
find . -type f -size +100000000c -exec ls -lrt {} \;
The result came out somthing like this:
-rw-rw-rw- 1 qa1wrk32 test 169263642 ...
2
votes
2answers
2k views
How to exclude a list of full directory paths in find command on Solaris
(Duplicated from Stack Overflow: http://stackoverflow.com/questions/7854975/how-to-exclude-a-list-of-full-directory-paths-in-find-command-on-solaris)
I have a very specific need to find unowned files ...
3
votes
2answers
368 views
find arcana: can't get pipe to work in -exec line
How do I pipe the results of a find through a sed to xform the stream, and then use that transformed stream as one of two arguments to a script? IE:
find turns up file1.tiff (among others)
sed ...
16
votes
7answers
20k views
Looping through files with spaces in the names?
I wrote the following script to diff the outputs of two directores with all the same files in them as such:
#!/bin/bash
for file in `find . -name "*.csv"`
do
echo "file = $file";
diff ...
5
votes
2answers
182 views
Collect files using find
I currently have this script:
find . -name '*.log' -print0 | xargs -0 tar zcf $file
To collect all the "*.log" files. I would like to modify it to include also all the ".txt" files but I don't know ...
4
votes
3answers
196 views
Best way to work through / display a tree of images sorted by size
I've got a deep directory tree containing .PNG files. I'd like to find all the .PNG files in the directory, sort them in order of size from smallest to largest, and then display every 50th image.
...
8
votes
6answers
482 views
Best way run a command on each file in a directory tree
There appear be a number of ways to do this including loops in shell script, find and xargs. Which of these is best, and which is most portable?