Link to home
Create AccountLog in
Avatar of techgenious
techgeniousFlag for United States of America

asked on

GREP & FIND

I am new to Linux and I'm in a file on a Linux box, and I am trying to find a number say '86'.

How to I find this in a linux text file.

I am in the actual file.

Can I use grep or find?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of jsdray
jsdray
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of woolmilkporc
What do you mean with "I'm in the file"?

Using an editor? vi/vim?

If it's vi/vim:

<ESC>/86<ENTER>

Repeat the search in the bottom direction with "n"
in the top direction with "N".

If you're paging through the file with "more" or "less" it's more or less the same.

Search with

/86

Repeat downwards with "n".
Avatar of techgenious

ASKER

I am in the actual file via 'vi' editor
So try my suggestion.

Hit <ESC> if you are in "edit"mode, then type a slash followed by your search string and hit <Enter>

Repeat the search by pressing n
Search in the opposite direction with N
that worked but then i get
'search hit BOTTOM, continuing at TOP'
does that mean no more search finds and starting from the beginning?

how do I get out of it?

Linux beginner
Yes, it has reached the end of the file and starts over from the top.

To get out of it hit <ESC>, then continue working on the file, e.g. by pressing i to enter insert/edit mode at the current cursor position,  or :wq!  (or :x )to save the file and exit, or :q! to exit without saving any changes.

Here is a short vi reference:
http://www.unix-manuals.com/refs/vi-ref/vi-ref.htm

Search the Web for "vi tutorial" or "vi manual" and you'll find a lot more stuff on how to use vi.
grep -r 86 filename