Hello Friends For one of us in GLT (as a part of MCA studies), i made these two scripts. Actually they are one script working in two directions that generate a list of files in a directory bigger or smaller than a particular size you specify.
But, in this script, because sed did not work with variable substitution, i used a very clumsy method of generating a temporary shell command 'comm.sh' that generates the full shell command and gets replaced by the next command. Can you suggest any better method of doing this? dipankar das 1. selectfile.big ========= #!/bin/sh [ -f ~/select.list ] && rm ~/select.list echo Generating ascending list of files bigger than given size.; echo -e "What is the lowest size you want? Give in kb:\c"; read givesize ls -sSr1 > ~/list; line=`wc -l ~/list | cut -c1-8`; wline=`expr $line - 1`; tail -"$wline" ~/list > ~/listt; i=1; while [ $i -le $wline ] ; do echo "sed -n '"$i","$i"p'" > ~/comm.sh seline=`cat ~/listt | sh ~/comm.sh`; size=`cat ~/listt | sh ~/comm.sh | cut -c1-5` ; [ $size -ge $givesize ] && echo "$seline">> ~/select.list; i=`expr $i + 1`; done [ -f ~/list ] && rm ~/list; [ -f ~/listt ] && rm ~/listt; [ -f ~/listtt ] && rm ~/listtt; [ -f ~/comm.sh ] && rm ~/comm.sh; cat ~/select.list; echo "Total number of files bigger than $givesize KB is:" wc -l ~/select.list | cut -c1-7 echo "List of selected file is kept in $HOME/select.list" 2. selectfile.small =========== #!/bin/sh [ -f ~/select.list ] && rm ~/select.list echo Generating ascending list of files smaller than given size.; echo -e "What is the lowest size you want? Give in kb:\c"; read givesize ls -sSr1 > ~/list; line=`wc -l ~/list | cut -c1-8`; wline=`expr $line - 1`; tail -"$wline" ~/list > ~/listt; i=1; while [ $i -le $wline ] ; do echo "sed -n '"$i","$i"p'" > ~/comm.sh seline=`cat ~/listt | sh ~/comm.sh`; size=`cat ~/listt | sh ~/comm.sh | cut -c1-5` ; [ $size -le $givesize ] && echo "$seline">> ~/select.list; i=`expr $i + 1`; done [ -f ~/list ] && rm ~/list; [ -f ~/listt ] && rm ~/listt; [ -f ~/listtt ] && rm ~/listtt; [ -f ~/comm.sh ] && rm ~/comm.sh; cat ~/select.list; echo "Total number of files smaller than $givesize KB is:" wc -l ~/select.list | cut -c1-7 echo "List of selected file is kept in $HOME/select.list" -- To unsubscribe, send mail to [EMAIL PROTECTED] with the body "unsubscribe ilug-cal" and an empty subject line. FAQ: http://www.ilug-cal.org/node.php?id=3
