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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-03-2010, 06:31 AM
|
#1
|
Member
Registered: Dec 2008
Posts: 36
Rep:
|
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".
|
|
|
01-03-2010, 06:32 AM
|
#2
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
1. grep.
|
|
|
01-03-2010, 06:36 AM
|
#3
|
Senior Member
Registered: Sep 2007
Posts: 1,047
Rep:
|
Quote:
Originally Posted by mech123
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>
|
|
|
01-03-2010, 06:37 AM
|
#4
|
Member
Registered: Dec 2008
Posts: 36
Original Poster
Rep:
|
please please describe in proper syntax and what is answer of 2nd question
|
|
|
01-03-2010, 06:39 AM
|
#5
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
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?
|
|
|
01-03-2010, 06:39 AM
|
#6
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
Quote:
Originally Posted by cola
Code:
cat file.txt | grep <pattern>
|
You don't need the cat - grep pattern file works.
|
|
|
01-03-2010, 06:42 AM
|
#7
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
Quote:
Originally Posted by mech123
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)
|
|
|
01-04-2010, 10:26 PM
|
#8
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,442
|
1. grep string file
2. :?string-to-find (? = search backwards)
|
|
|
All times are GMT -5. The time now is 05:56 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|