Tagged Questions
1
vote
3answers
78 views
Setting file permissions in bash script
This script is not working the way I thought it would .I though it would find all the scripts that have every one rwx permissions changed to the permissions of xx5
#!/bin/bash
# the / makes find ...
3
votes
2answers
94 views
How to run "find -exec <script> {}\;
I have a script that changes the properties of the files for a folder.
Here is the example tree:
dir 1
--file 1
--file 2
--file 3
dir 2
--file 1
--file 2
dir 3
--file 1
...
2
votes
2answers
390 views
list all files newer than given timestamp and sort them
I want to list all files (sorted by date) that are newer than timestamp in format 20130207003851 in directory /tmp only. Subdirectories can be omitted.
Using SUSE Linux Enterprise Server 11.
The ...
2
votes
1answer
227 views
Help me parse this `find` command
Following command tells me the length of mp4 video files:
find -type f -name "*.mp4" -print0 | \
xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | \
perl -nle ...
3
votes
3answers
561 views
Preserve directory structure when moving files using find
I have created the following script that move old days files as defined from source directory to destination directory. It is working perfectly.
#!/bin/bash
echo "Enter Your Source Directory"
read ...
-1
votes
1answer
103 views
Error while running bash script that moves files
I am new to bash script and want to create bash script that moves some days old files between source and destination as per days defined in script.
When I run this script I get error
find: paths ...
7
votes
4answers
987 views
Executing user defined function in a find -exec call
I'm on Solaris 10 and I have tested the following with ksh (88), bash (3.00) and zsh (4.2.1).
The following code doesn't yield any result:
function foo {
echo "Hello World"
}
find somedir -exec ...
5
votes
3answers
3k views
Find files which are created a certain time after or before a particular file was created
I need a shell script which finds files which are created 1 hour before or 1 hour after a particular file (test.txt) was created.
If I go with find -newer, that means I'd have to create a temporary ...
4
votes
2answers
131 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
1answer
107 views
How to have find only search for files in changed directories?
Currently I'm repeatedly doing a 'find' that's too slow. I'm searching for non-hidden executable files within "$root", excluding "$root/bin":
find "$root" -type f -perm -o+x -not -path "$root/bin/*" ...
6
votes
3answers
2k views
find -exec in bash script with variable expansion
I'm trying to run a command similar to the one below in a bash script. It should search through all subfolders of $sourcedir and copy all files of a certain type to the root level of $targetdir.
...
2
votes
3answers
2k views
How to search and replace text in all php-files in a directory and it's subdirectories
I am looking for a shell script that recursively traverses all .php files in a directory and performs a search & replace of a particular text pattern.
The search pattern is quite long ( > 5000 ...
3
votes
1answer
111 views
'find' across directories named …/dirnameXX/… with XX variable
I am executing this command to find certain files in specific directory:
find ./rgs/test/maesXX/master/stdlist -name \*.extract \
-mtime +30 \! -size 0 -exec ls -lrt {} \;
where XX could be ...
3
votes
1answer
379 views
Storing `find` parameters in a variable
I'm running the following bash command:
find . \( -iname '*.aif' -o -iname '*.pdf' -o -iname '*.exe' -o -iname '*.mov' \
-o -iname '*.doc' \) -exec rm -f {} \;
I'm running the same parameters ...
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.
...