06-06-2008
Just to close this thread off, here's the solution since noone else came up with something easier:
function something {
# $1 = the directory to search from
# $2 = timeframe to check
echo 1 > ${RESULT_FILE}
find ${1} -mtime -${2} -exec ${LOCAL}/kill_find.ksh ${1} ${2} ${RESULT_FILE} {} \;
sleep 2
result=`cat ${RESULT_FILE}`
rm -f ${RESULT_FILE}
return $result
}
week=No; month=No; month6=No; year=No; year2=No
if something "${DIR}/${j}" 7
then
week=Yes; month=Yes; month6=Yes; year=Yes; year2=Yes
elif something "${DIR}/${j}" 30
then
month=Yes; month6=Yes; year=Yes; year2=Yes
elif something "${DIR}/${j}" 180
then
month6=Yes; year=Yes; year2=Yes
elif something "${DIR}/${j}" 365
then
year=Yes; year2=Yes
elif something "${DIR}/${j}" 730
then
year2=Yes
fi
and seperate function:
#!/bin/ksh
kill -9 `ps -ef | grep -v grep | grep "find ${1} -mtime -${2}" | awk '{print $2}'`
rm -f ${3}
echo 0 > ${3}
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Does anyone know of a good Internet source that explains the directory structure of Unix/Linux??
Thanks
Gregg (2 Replies)
Discussion started by: gdboling
2 Replies
2. UNIX for Dummies Questions & Answers
Hi all
Is it possible to copy a structure of a directory only.
e.g.
I have a file with the following entries that is a result of a find :-
/dir1/dir2/file.dbf
/dir1/dir2/dir3/file1.dbf
/dir1/file.dbf
I want to copy these to a directory and keep the structure however starting at a new dir... (8 Replies)
Discussion started by: jhansrod
8 Replies
3. UNIX for Advanced & Expert Users
Hi,
I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)
Discussion started by: srmadab
4 Replies
4. UNIX for Dummies Questions & Answers
Hello,
I just want to ask the following use of find command:
1. how can I find files only to the current directory?
2. how can I find files to directories and all subdiretories (are this include soft links?) but will not go to other mountpoints that is under that mountpoint.
Im combining... (1 Reply)
Discussion started by: james_falco
1 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I'm new here so hello to everyone...i'm also new to linux/unix but got my first dedicated server about 2 weeks ago and have been using ssh to configure it on ubuntu linux.
I have a question about something i can't work out....if i use ftp to transfer files ( php, html, javascript files... (2 Replies)
Discussion started by: elduderino
2 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I want to list all the last directories from mentioned base path.
for eg: If i have a base path say /base/base1/
How can i get the path till last node in tree like directory structure of unix by applying any command.
so that i will get following output.
... (7 Replies)
Discussion started by: Shiv@jad
7 Replies
7. Shell Programming and Scripting
I'm using this now:
find /some/path/with/sourcefiles -type f -size -7M -exec /bin/cp -uv {} /some/path/ \;
but it doesn't preserve the directory structure, also I've tried it with
find /some/path/with/sourcefiles -type f -size -7M -exec /usr/bin/rsync -auv {} /some/path/ \;
but that doesn't... (9 Replies)
Discussion started by: unclecameron
9 Replies
8. UNIX for Dummies Questions & Answers
Hi All,
im a new guy if it comes to Unix. I am trying to auto categorize Nzbget downloads the most basic way. I already manage to find files within the directory i'm at and move them with if check to a certain dir. Unfortunately this command is restricted to the directory i'm at and does not... (2 Replies)
Discussion started by: RoxXxoR
2 Replies
9. UNIX for Dummies Questions & Answers
Hi there, I'm trying to pull all my flacs out of my Music collection. I can do it with following command
find b/ -name *.flac -exec mv {} flac/ \;
which works great except it moves all the flac files to the flac folder. I want it to recreate the original folder the flacs were found in and mv... (8 Replies)
Discussion started by: fistikuffs
8 Replies
10. UNIX for Dummies Questions & Answers
Hi everyone, I'm a new member at the forum I mistakenly posted this elsewhere too.
I have a file like this: field 2 values are either 0 or negative. file test4:
100815 -20
118125 0
143616 0
154488 0
154488 0
154488 -6
196492 -5
196492 -9
196492 -7
27332 0... (5 Replies)
Discussion started by: meet77
5 Replies