LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-14-2006, 04:04 AM   #1
just_a_kid
LQ Newbie
 
Registered: Dec 2006
Posts: 24

Rep: Reputation: 15
how to search backwards using more


hi anyone know how to search particular string backwards using more/less command


i know
typing
/ ==> will search forward


in vi we use shift+G
type /some string
and shift+N will search backward


Thanks.
 
Old 12-14-2006, 04:20 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
If I've not misunderstood your question, you can search for the expression using /, but then to scroll through the results, you hit n for scrolling forwards, and shift+n for backwards, much like vim. I think less highlights all occurrences of the expression, both forwards and backwards from your current position in the file, then you just scroll through them, either forwards or backwards.

Hope this helps.
 
Old 12-14-2006, 04:26 AM   #3
just_a_kid
LQ Newbie
 
Registered: Dec 2006
Posts: 24

Original Poster
Rep: Reputation: 15
hi here is what i did

i type

bash> more some_log.log

then i type
/some string [ Enter ]
i hit n ( it works )
i hit shift+n ( it doesnt work )


any idea??
 
Old 12-14-2006, 04:32 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
I've had a look in the more man page and it doesn't seen to mention a backwards search function. However, the less manpage has this to say:
Quote:
Less is a program similar to more (1), but which allows backward movement in the file as well as forward movement.
So it seems more can't do backwards, which is why they wrote less.
 
Old 12-14-2006, 05:50 AM   #5
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 729

Rep: Reputation: 75
Hi.

While you are viewing a file with less type "h", and a help page will be displayed. It will show both ways of searching backward: the method described above, as well as with "?string" instead of "/string" as in vi ... cheers, makyo
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Time goes backwards DoubleLetter Linux - General 6 11-02-2007 05:38 PM
where is backwards E? Four Linux - Newbie 8 10-14-2006 12:44 PM
Backwards Clustering? ImpactDNI Linux - Networking 6 06-29-2004 02:44 PM
Quick VIM question (unhighlighting search terms after search) lrt2003 Linux - Newbie 5 05-08-2004 05:21 PM
move backwards alaios Linux - General 1 03-14-2004 02:21 PM


All times are GMT -5. The time now is 08:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration