Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
trying to provide a list of locations to search using find for files that have been modified in last 24 hrs. Can get appropriates results running manually but not in script. I've tried a few different syntaxes but not hitting the right one.
Here's part of the code:
#!/bin/kshwhile read LINE
do
echo $LINE
find /$LINE -type f -mtime -1 -exec ls -al {} \; >/$OUTFILE
done <$INFILEThe input file only lists directory names without the leading slash (ie. home). I'm trying to get this to run for local disk and SAN attached disk. Also need it to run on AIX 5.3, Solaris 8 and Redhat 4. It is reading the input file correctly and echoing the lines. It also creates the output file correctly. Seems to read local but not SAN attached disk. Am I missing a switch to follow links? tried -follow
On Solaris it runs slow like it's reading SAN drives but doesn't produce any results even for local disk. On AIX, it skips past SAN drives quickly and produces results on local disk.

First, are you sure that you have write permissions on this file?
/$OUTFILE
Second, if any of your directory objects contain spaces, you probably need to use double quotes around $LINE:
find "/$LINE" -type f -mtime -1 -exec ls -al {} \;
Also, spaces in the directory names or files could cause you other problems. Take a look at this column:
http://www.unixreview.com/documents...
(It also discusses using xargs instead of find's -exec)
third, consider checking that the directory exists before executing the find:
if [ -d "/${LINE}" ]
then
find ...
fi

definitely have write permissions on $OUTFILE. Running as root and the script creates that file so created as same user.
no spaces in the directories.
And the directories definitely exist. $INFILE is manually created unique to each server to list the file systems that want to search.I'm probably running into a shell problem. Tried doing a which find and forcing to use the same find cmd. ie THISFIND=/usr/bin/find.
Also tried changing script to bash...
Just one of those things that's driving me nuts.
Thanks for feedback though.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |