Mr_Munkey
03-05-2003, 03:27 PM
Hi all,
I'm pretty new to linux, but I learn fast. I'm running SuSE linux 8.1 (FTP install if you want to know) That's probably not important.
here's the problem. I'm working on a shell script to do an automatic archive of files that are older than a certain date, and set it up with cron. This is kind of how it goes:
make sure user is root
ls -l > /mydirectories.txt
now, when I want to check the ownership of those directoris I'm trying to use awk to accomplish my task. I want it to go through each directory one at a time, so I've set it up in a while loop.
while [ "$COUNT" -le "$NUMDIRS" ]
do
if [ "$DIROWN" != "root" ]
then
blah blah blah
fi
COUNT=`expr $COUNT + 1`;
DIROWN is the problem it is :
DIROWN=`awk 'NR == $COUNT {print $3}' /mydirectories.txt`;
I dont know how to use a variable to get the corresponding line in the text file inside of the loop (starting at 2 because awk tells you how many lines there are on the first line)
the loop is working fine, it's just the if statement checking the ownership of the file.
Thanks in advance for any help
PS> just in case, my email is admin@mrmunkey.no-ip.org
I'm pretty new to linux, but I learn fast. I'm running SuSE linux 8.1 (FTP install if you want to know) That's probably not important.
here's the problem. I'm working on a shell script to do an automatic archive of files that are older than a certain date, and set it up with cron. This is kind of how it goes:
make sure user is root
ls -l > /mydirectories.txt
now, when I want to check the ownership of those directoris I'm trying to use awk to accomplish my task. I want it to go through each directory one at a time, so I've set it up in a while loop.
while [ "$COUNT" -le "$NUMDIRS" ]
do
if [ "$DIROWN" != "root" ]
then
blah blah blah
fi
COUNT=`expr $COUNT + 1`;
DIROWN is the problem it is :
DIROWN=`awk 'NR == $COUNT {print $3}' /mydirectories.txt`;
I dont know how to use a variable to get the corresponding line in the text file inside of the loop (starting at 2 because awk tells you how many lines there are on the first line)
the loop is working fine, it's just the if statement checking the ownership of the file.
Thanks in advance for any help
PS> just in case, my email is admin@mrmunkey.no-ip.org