LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-23-2003, 07:50 PM   #1
Samsara
Member
 
Registered: May 2003
Distribution: Ubuntu, Mac OS X Tiger
Posts: 481

Rep: Reputation: 32
vim 'n' lynx: command line option to search for string


Hi All!

I've looked at man and info pages, but can't figure out how to pass an argument to lynx and vim on the command line that will highlight all occurences of a given string. I'm thinking something like

vim --search-string=highlightme $foo.txt
lynx --search-string=highlightme $foo.html

Can this be done? Any alternatives?

Thanks,

Samsara
 
Old 08-23-2003, 08:24 PM   #2
martinman
Member
 
Registered: Apr 2003
Distribution: Gentoo 1.4
Posts: 290

Rep: Reputation: 30
in vim you can search by typing "/ searchterm"
 
Old 08-23-2003, 08:38 PM   #3
Samsara
Member
 
Registered: May 2003
Distribution: Ubuntu, Mac OS X Tiger
Posts: 481

Original Poster
Rep: Reputation: 32
Quote:
Originally posted by martinman
in vim you can search by typing "/ searchterm"
Yeah, sorry I should have mentioned that. I want to do it from the command line, because I have a lot of files to go through and a fetish for automating things

Cheers,

Samsara
 
Old 08-23-2003, 09:31 PM   #4
seabass55
Member
 
Registered: Jan 2003
Location: 127.0.0.1
Distribution: Fedora&Gentoo
Posts: 207

Rep: Reputation: 30
have you tried grep?
 
Old 08-24-2003, 11:52 AM   #5
Samsara
Member
 
Registered: May 2003
Distribution: Ubuntu, Mac OS X Tiger
Posts: 481

Original Poster
Rep: Reputation: 32
Quote:
Originally posted by seabass55
have you tried grep?
Oh, I use grep lots, but it's not the same: for instance, in grep you can't tell whether something is a tab or a space, if you see what I mean... grep is really good for predictable situations, e.g. where you know exactly how many context lines you will need, but you won't always have that prior information.

Thanks anyway,

Samsara
 
Old 01-02-2013, 06:20 PM   #6
jphase
LQ Newbie
 
Registered: Jan 2013
Posts: 2

Rep: Reputation: Disabled
Wink Sure you can

Quote:
Originally Posted by Samsara View Post
Oh, I use grep lots, but it's not the same: for instance, in grep you can't tell whether something is a tab or a space, if you see what I mean... grep is really good for predictable situations, e.g. where you know exactly how many context lines you will need, but you won't always have that prior information.

Thanks anyway,

Samsara
Hey, this might be old or what-not, but I figured I would reply anyhow for Googlers.

Yes, you can do this. Start by outputting the source code with lynx and then we can strip the characters from there with sed and a simple regex. For example, to get your ip address from http://ipaddress.com:

Code:
lynx http://ipaddress.com -source | grep 'My IP Address' | tail -n1 | sed 's/<[^>]*>//g'
output source code from ipaddress.com | search for 'My IP Address' | print out last line | strip <html> tags

Further stripping of text can happen afterwards. Just check for "sed find and replace" in Google and pipe the output to the command. If you need something more complex after that, I would actually recommend using a scripting language.

Last edited by jphase; 01-02-2013 at 06:23 PM.
 
Old 01-02-2013, 06:36 PM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870
Just for completeness, with Vim you can use the -c option to give Vim commands to execute after opening a file, this works also with searches.
 
  


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
escape string in bash script so it can be used in command line BuckRogers01 Linux - Software 15 08-12-2010 09:38 AM
Command line option -F means what? TSynergy Linux - Newbie 5 11-15-2005 08:01 PM
Downloading files with lynx directly via command line Dade Linux - Software 5 06-11-2005 01:43 PM
vim search and replace - split line phreak7t7 Programming 2 08-16-2004 05:02 PM
Command line to search where's the apllication installed mikeccs Linux - Newbie 7 07-23-2004 07:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:27 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
Open Source Consulting | Domain Registration