LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   search string command (https://www.linuxquestions.org/questions/linux-newbie-8/search-string-command-779539/)

mech123 01-03-2010 06:31 AM

search string command
 
1.i want to know command for search a string in file without opening file from vi editor.
2nd question.when i open file with vi editor in linux, i can search string by (in esc mode) "/search_string" command. This will search string from starting of file what will be command if i want to search string from "end of file" in "vi opened file".

Nylex 01-03-2010 06:32 AM

1. grep.

cola 01-03-2010 06:36 AM

Quote:

Originally Posted by mech123 (Post 3812348)
1.i want to know command for search a string in file without opening file from vi editor.
2nd question.when i open file with vi editor in linux, i can search string by (in esc mode) "/search_string" command. This will search string from starting of file what will be command if i want to search string from "end of file" in "vi opened file".

Code:

cat file.txt | grep <pattern>

mech123 01-03-2010 06:37 AM

please please describe in proper syntax and what is answer of 2nd question

pixellany 01-03-2010 06:39 AM

You can use various utitlities to search file---eg GREP, SED, AWK

As for the VI question, does the manual (or man page) say anything about this?

Nylex 01-03-2010 06:39 AM

Quote:

Originally Posted by cola (Post 3812355)
Code:

cat file.txt | grep <pattern>

You don't need the cat - grep pattern file works.

pixellany 01-03-2010 06:42 AM

Quote:

Originally Posted by mech123 (Post 3812356)
please please describe in proper syntax and what is answer of 2nd question

What do you mean by "proper syntax"? I don't see any syntax mistakes here. For any of these commands, the man page will give you the syntax.

Do you have some kind of reference material? (e.g. the Bash Guide for Beginners)

chrism01 01-04-2010 10:26 PM

1. grep string file
2. :?string-to-find (? = search backwards)


All times are GMT -5. The time now is 11:32 AM.