General :: Using Grep / Awk To Search For Colored Text
Sep 17, 2010
I have done a bunch of searches on this but the terms seem to get tangled in the more popular search of "colouring the output of grep / awk". I am trying to find a way to grep/awk through the output of a command to find text of a specific colour. The command's output has a range of colours signifying too many different things to specify using text, with colour being the only form of grouping.
I'd like to search the entire server by content. (text file) When I try grep -rl "text here", it freezes. How would you do it? And how long does it usually take?
I am using ascript for general users to back up usb drives to lto4 tapes.. I wish to ahve some error checking to check IF is there is a tape in the tape drive to check for the tape:
if i do a sudo mt -f /dev/st0 status i will get back a mt: /dev/st0: rmtioctl failed: Input/output error if there is no tape in the drive or sudo mt -f /dev/st0 status
I need to search for the following pattern with GREP in a text file:
So I tried already:
But none of those works...I think probably because GREP doens't like the special character > in the middle of the serach pattern.
At the end I just need to now if GREP found the pattern in the file or not, so it should give me a 0 or a 1 back, once I check the value of the variable "?" after using the grep command.
I've been trying to identify all files on my cut-down version of Damn Small which contain the text string "User Agent:" in them. Because it's only 120Mb in its entirety, I'm quite happy to have grep search the whole system. I'm using this command, but it just generates errors as you can see:
To search a string pattern in all files in a directory and subdirectories, I am using;
Code: grep -R "myclass::my-func(" mydirectory/ Now I want grep, to search in only specific file types say *.cc. Please help me. I have read manual of grep, but could not deduce any hint. Best Regards.
I have an annoying text color problem. I don't know what to change to fix it. I have played around with System->Preferences->Appearance to no avail. Here is the problem: I am getting very light colored text so only the currently selected item is readable. The funny thing is that in Nautilus, Firefox, Chrome, Amarok, etc.. it's fine. It seems to be in only some programs in boxes with selectable line items, but also in the area that displays status updates in FileZilla. So I'm not sure how to pinpoint the problem.
I recently upgraded to Ubuntu 10.4 and, although that installation seemed to work OK for awhile, I have recently encountered a strange problem. I have a dual-boot system with Win XP and two releases of Ubuntu, 10.4 and 9.10. I installed the latter recently only to be able to run some legacy software. I believe the problem occurred sometime around or after the installation of the 9.10 package. Note that the 10.4 install was a clean install on a newly formatted HD, and not a normal upgrade from 9.10, which I installed later separately. The Ubuntu installations are on their own HD. Win XP is installed on its own separate HD.
Here's the problem. I can boot OK up to and including the appearance of the Grub 2 menu, which displays fine. From the menu I can chose Ubuntu 9.10, Win XP or several kernels of 10.4. The 9.10 Ubuntu boots completely normally, as does Win XP--no problems or irregularities with either of those. When I select one of the 10.4 Ubuntu kernels, the strangeness begins, as follows:
1.) The menu disappears, there is a brief period of blank screen, and then a bizarre screen appears. It has a violet/magenta background. The word "Ubuntu" appears in large type, with a couple of lines of text below it. However, all of the type is unreadable. Instead of being normal characters, all the text characters are displayed as blocks of seemingly random multi-colored pixels! I can recognize that it is supposed to be text, but the letters are just a bunch of colored pixels. I can recognize the large Ubuntu word because of its shape. Also, the whole text display occurs twice on the screen, one on the left and one on the right. Both are displayed as colored pixels.
2.) The screen stays there, as if frozen, and does not continue with installation of the kernel. After some experimenting, I discovered that if I press Ctrl-Alt-Del (!), the installation continues as one would expect: I soon get the normal login screen, am able to login OK, and my desktop soon appears as usual.
3.) However, once in the desktop, if I try to invoke a console window by pressing Ctrl-Alt-F1-6, the console window appears, but the text on the screen is again rendered as little bunches of colored pixels, completely unreadable. I can, in fact, login at these screens, but the text remains colored pixels. I can escape back to a normal desktop by then pressing Ctrl-Alt-F7, and the desktop comes back completely normal. Interestingly, if I invoke a terminal from the main Applications/Accessories/Terminal menu, I get a normal terminal in a desktop window that is perfectly usable.
4.) If, from the boot menu, I choose the Ubuntu 9.10 choice, everything works fine and as expected, including the Ctrl-Alt-F1-6 console windows. This problem only occurs with the Ubuntu 10.4 menu options.
Since this problem only occurs with the Ubuntu 10.4 menu choices, my guess is that there is something askew in the display configuration of those specific choices. But, I've not discovered what to check for that configuration or how to correct it. I've checked out the /boot/grub/grub.cfg file, the /etc/grub.d number files, and /etc/default/grub, but can't find anything that seems to be the cause or the remedy.
Q: Is there any way to use grep and sed with a string variable rather than with a file?
The problem: Im running through a LARGE (about 10,000 lines) xhtml file and need to replace every instance of lines beginning <p>~
The following code works but takes a long time mainlly because an in/out operation needs to be carried out on each line. If I could read from a string rather than a file it would take a much shorter time!
I have a list of words that I want to grep in many files to see which ones have it and which ones dont. in the text file I have all the words listed line by line, ex: list.txt:
check try this word1 word2 open space list ..
I want to grep each line one by one. like I want it to
grep "check" *.log grep "try this" *.log grep "word1" *.log .. etc how can I do this?
I'm trying to manipulate a large text file full of records (metadata - one complete record per line). I need to delete every line on which certain words appear - there are five different words, all pretty simple all-caps strings with occasional whitespace. I tried using grep -v, which worked a treat, but only string-by-string. Ideally I'd like to run this as grep -v -f, where the file targeted by the -f contains the strings I need to match in order to delete the lines they're in.
i.e. grep -v -f filecontainingSTRINGS.txt targetfile.txt > outputfile.txt
When I try this, however, I don't get any matches - or more specifically, no changes are made in the output file. It works fine if there's only one string in filecontainingSTRINGS, but it doesn't work if there's more than one (I'm using newline as the delimiter). (Also my machine doesn't recognise /usr/xpg4/bin/grep - no idea what that's all about!)
I need to search for a string "teststring" in all *.java files coming under /home/user1/ (including subfolders). How can I do it in linux via shell command.
I have a html page and I would like to search for the occurance of a given string as an anchor. Then I would like to search backward for a the first match to a given regular expression. As a result I would like to output the text between the two points.
Please note that I would like to have the output up to the first regex match before the ANCHOR point.What is the best tool to solve this?
Long story short, I got a folder with nearly 800,000 php files. I would like to search each file for a string and if it exists in that file, the file gets copied to another directory. Is this possible from the terminal? So far I got: grep -i -n -r 'ppr-1792' * | cp $1 move_to_here
But this obviously doesn't work. $1 needs to be the file name that contains matching text.
how to search in files text that is one-byte encoding? places - search for files in gnome in ubuntu searches only utf-8 text.i know one way: install wine and total commander, then search with it. what are better ways?[URL]
[Syenite] RegionUUID = 8fc56fdd-0afd-4074-9432-0ae8f42b799f Location = 9992,10007 InternalAddress = 0.0.0.0 InternalPort = 9000 AllowAlternatePorts = False ExternalHostName = 71.171.21.9 What I need to do is find out what the IP address is after "ExternalHostName ="
After that I will need to compare that IP to whatismyip and if it's different then replace it but that is easy to do with sed. I just can't figure this simple hurdle out.
I've got a big text file in which I know have probably made some typos (LaTeX). Sometimes I rewrite sentences several times and then end up with double pieces like "the the" or "is is" without noticing it. Most spell checkers that I can use in LaTeX are very basic so they do not notice these grammar errors. Is there a way that I can search for these repetitions by hand using sed or awk or something along these lines? Is there an app for that?
I have a mail.log file, of which I want to redirect only the search strings of the sender from=<example.sender@exampledomain.com> and the size size=4537 to a file.
In every case the sender string starts as from=<> and the size string starts as size=
What would be the grep command to redirect only the two search strings to a .txt file?