Linux - NewbieThis 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.
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.
I am trying to use the grep command but I cannot manage, I know it can be done so I need help.
I am connected to the sane site and I have its sane supported devices for linux table on my xorg screen.
And I want to "grep" and print from the 1777 registered devices the 333 scanners that have complete support.
I tried:"$ grep xorg sane scanners complete" which of course is silly, wishing to tell grep that the file is at the screen etc! I got "no such file". I tried other silly commands to no avail.
What application is displaying the data on that screen? A terminal? A text editor? A browser? If it's Firefox, you can search for text in the page by pressing Ctrl-f.
To use grep you will need to save the data to a text file.
I have never tried to use grep by itself. It is a program that 'filters' input, and gives you the filtered output matches.
Example. If you go to your home directory, and run the command 'ls', the output to the screen will be the files and directories that are not hidden. There may be many lines. If you are looking for all directories and files with a letter f in them ( just an example ) the command 'ls | grep f' would do it. The input comes from ls. The vertical bar is the 'pipe' command. It directs the output of ls to grep. Grep does the filtering you set up, in this trivial example the filter is 'f'.
You could search through a file is you used the 'cat' command. ie 'cat myfile | grep stuff'. The output would be a line for every time 'stuff' appears in the file.
Maybe I misunderstand what your doing: You have a website open in a browser (e.g. firefox) and try to grep in there? That does not work. Grep works on a file, not on a screen.
I did the following:
saved http://www.sane-project.org/sane-mfgs.html as a text file (sane.txt); do not save a s webpage as it contains to much crap for this purpose
next I ran the command below
Code:
grep -i complete sane.txt >complete.txt
The -i will make the grep case insensitive and the output goes to a file complete.txt
PS
For more complex stuff (e.g. scanner and complete), you can pipe the output of the first command through a pipe to a new grep (for scanner) and redirect the output to e.g. scanner_complete.txt
Last edited by Wim Sturkenboom; 07-22-2010 at 06:11 AM.
Presuming you are looking at a web page, use something that understands http, but doesn't render the page - curl is good. Pipe it straight into grep, or save it to a file for processing.
Thank you everybody, I did not expect such a fast answer so I did lose some time.
Here is what I am trying to do first i.e. save the firefox sane page "http://www.sane-project.org/sane-mfgs.html" to a file. So I went: "$ mkdir sane.txt" and made a directory (that is a file?) in my home. Then I tried to save the sane page as text from firefox bar: file>save page as>home>jv>sane.txt but it does not go (saved) to sane.txt. I tried to save the page as text and as full page.So here I am stuck! You understand that I know almost nothing about computing.
Sorry but I had already saved the page as text in my home. It did not save itself in the recently made "sane.txt" directory which I was informed about after trying to save the page simply in /home, experimenting!
then I ran:grep -i complete sane.txt >complete.txt but got: there is no such file or directory.
I did try the following successfully: "cat sane-mfgs.html | grep Complete" and I got all scanners with complete Linux support and some with complete no support!
I had some difficulty to print the 10 resulting pages as I had to manually
'print screen', neither xterm or konsole would print the whole page.
That was a very good lesson for me and thank you all for your support and time. I know that it is frustrating for a teacher who faces somebody like me that lacks the basics.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.