Search Within Your Pager


If you're using less to view a large file or an especially dense one, it can be difficult to find the text in which you're particularly interested. For instance, what if you want to know if Milton uses the word apple in Paradise Lost to describe the fruit that Adam and Eve ate? While in less, press / and then type in the pattern for which you'd like to searchand you can even use regular expressions if you'd like. After your pattern is in place, press Enter and less jumps to the first instance of your search pattern, if it exists. If your pattern isn't in the file, less tells you that:

Pattern not found (press RETURN) 


Repeating your search is also easy and can be done either forward or backward in your file. Table 5.2 covers the main commands you need for searching within less.

Table 5.2. Search Commands for less

Key Command

Action

/pattern

Search forward for pattern using regex

n

Repeat search forward

N

Repeat search backward


Note

No, Milton never explicitly refers to the fruit as an apple; instead, it's just a "fruit." Yes, I worked on a doctorate in Seventeenth Century British Literature for a number of years. No, I didn't finish it, which explains why I'm writing this book and not one solely devoted to John Milton and Restoration literature.




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net