Hi,
I need your help.
Suppose I have a directory called /home/rooh
This directory contains files and directories.
For ex
drwxr-xr-x 3 rooha arboradm 96 Apr 6 03:24 batches
drwxr-xr-x 2 rooha arboradm 96 Apr 6 03:21 worker
-rw-rw-rw- 1 rooha arboradm 12661 Apr 4 05:46 RLO00220404144142ENG01
-rw-rw-rw- 1 rwata arboradm 16761 Apr 4 05:46 PD0022040414414200000AF-000
-rw-rw-rw- 1 rwata arboradm 13895 Apr 4 03:44 RLO00220404123602ENG01
-rw-rw-rw- 1 rwata arboradm 18586 Apr 4 03:44 SOR022040412360200000AF-000
-rw-rw-rw- 1 rwata arboradm 13749 Apr 4 03:44 SOR022040412360200000AF-001
-rw-rw-rw- 1 rwata arboradm 11974 Apr 4 03:44 RLO00220404123602ENG02
Now I want that I should list only the files and not directories and put them in a file.
So this is what I do:
cd /home/rooh
ls -al |grep ^->>/tmp/fileslist
So that looks fine. My /tmp/filelist contains only files and no directories.
Now what I want is that move the files from /home/rooh to /home/rooh/RIM/APRIL on the basis of size.
Means First I just want to move files till the size is less than 200000.
So I thought of doing something like this.
FILESIZE=0
for file in `cat /tmp/fileslist`
do
{
FILENAME=`cat $file |awk '{print $9}'`
#FILE=`cat $FILENAME |cut -f7 -d "/"`
SIZE=`cat $file |awk '{print $5}'`
if [ $FILESIZE -lt 200000 ]; then
{
mv $FILENAME /home/rooh/RIM/APRIL
[ $? = 0 ] && /bin/printf "$FILE\n " >> $LOGFILE
FILESIZE=`expr $FILESIZE + $SIZE`
}
else
/bin/printf "File size is $FILESIZE."
exit 1
fi
} done
But It gives me various error messages. Can you please suggest what i should do.
Or is there an alternate way of doing this.
Basically I just want to move files until the size is less than 200000.
Your suggestion will be highly appreciated.
Thanx a ton in advance for your valuable advice.
Rooh