Register
It is currently Thu Jul 24, 2014 7:03 am

Using Less or More?


All times are UTC - 6 hours


Post new topic Reply to topic  [ 6 posts ] 
Author Message
 PostPosted: Sun Jan 30, 2011 2:37 am   

Joined: Fri Jan 28, 2011 9:32 am
Posts: 3
Dear all,
I'm a beginner of bash scripting, i'm stuck on the following issue maybe someone could help me with this easy thing i think,
thanks a lot

I have made a simple search to files. Via for loop it posts all the find files (using echo) to the screen
but when there are more results like 30, it scrolls down to the screen, now im looking for a way to use More
to i can see all the results and using the space bar the next ones.
using echo .... | More does not work or echo .... |less also not/

Thanks
regards
Tidde


Top
 Profile  
 PostPosted: Sun Jan 30, 2011 2:54 am   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
Please provide the script you made. Just copy+paste it between [code] and [ /code] tags. That way we can actually see why it isn't working.


Top
 Profile  
 PostPosted: Sun Jan 30, 2011 3:22 am   

Joined: Fri Jan 28, 2011 9:32 am
Posts: 3
Sure no problem see below

Code:
echo "Search for $1 "

for logfile in `find $path1/Zotero\ data/storage/ -type f -iname $**`
do
logarr[$logcnt]=$logfile

ext=${logfile#*.}
if [ $ext != "gif" ] && [ $ext != "jpg" ] && [ $ext != "swf" ] && [ $ext != "css" ] && [ $ext != "png" ] ; then

echo $logcnt  $logfile  | awk  -F/  '{print $1 $7;}'   !!!!!!!!!!!!!!!!!!here it echo the results !!!!!!!!!!!!!!!!!!!!!
((logcnt=$logcnt+1))

fi

done
echo "Enter choice to view/edit :"
read choice
clear
case "${logarr[$choice]##*.}" in
txt)

echo "Do you want to (e)dit or (v)iew or (o)pen folder?"
read ev
if [ $ev = "e" ]
then
nano  ${logarr[$choice]}

elif [ $ev = "v" ]





Top
 Profile  
 PostPosted: Sun Jan 30, 2011 4:05 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 532
Code:
echo "abc
def
ghi" | more
works fine; with less too.


Top
 Profile  
 PostPosted: Sun Jan 30, 2011 4:52 am   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
Put the | more right after your done loop.


Top
 Profile  
 PostPosted: Sun Jan 30, 2011 5:41 am   

Joined: Fri Jan 28, 2011 9:32 am
Posts: 3
Awesome it works!! , great
Thanks a lot
regards
Tidde


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP