One of the renowned search tool on Unix-like systems which can be used to search for anything whether it be a file, or a line or multiple lines in file is grep utility.

#batman#dc#dc comics#bruce wayne#dick grayson#batfam#batfamily#tim drake#dc fanart



seen from United States
seen from Germany
seen from Philippines
seen from United States

seen from Germany

seen from United States

seen from Germany

seen from Singapore
seen from United States
seen from China

seen from Sri Lanka
seen from India
seen from China
seen from United States

seen from United States

seen from Germany

seen from France

seen from Singapore
seen from Serbia

seen from France
One of the renowned search tool on Unix-like systems which can be used to search for anything whether it be a file, or a line or multiple lines in file is grep utility.
Expressões Regulares no Linux
Expressões Regulares no Linux
Vamos falar sério. Tirem as crianças da sala. Se você não sabe um tiquim de expressões regulares, você não sabe Linux ainda. É igual ter um Iate para andar na piscina de casa.
Uma expressão regular é um método formal de se especificar um padrão de texto a ser procurado em um ou mais arquivos.
É uma composição de caracteres com funções especiais (metacaracteres) que agrupados entre si com…
View On WordPress
Highlight log using grep with color context
From everythingsysadmin comes the handy tip that to colorize selected output in a file, but retain the context around it we can use the ^ pattern in a regex to match all files.
$some-command | egrep --color=always '^|running|waiting'
Δαμάζοντας το grep - 7+1 διαφορετικές χρήσεις του
Δαμάζοντας το grep – 7+1 διαφορετικές χρήσεις του
Το grep utility είναι ίσως ένα από τα πιο δημοφιλή εργαλεία στο linux. Χρησιμοποιείται για να φιλτράρουμε τα αποτελέσματα της εξόδου εντολών ή στην αναζήτηση συγκεκριμένων λέξεων μέσα σε ένα αρχείο. Σε αυτό το άρθρο προσπαθούμε να πάμε λίγο παρακάτω σε σχέση με αυτό που γνωρίζουμε οι περισσότεροι για το grep και να αναδείξουμε την πραγματική δύναμη του. (more…)
View On WordPress
egrep: character class syntax is [[:space:]], not [:space:]
Writing complex regex expressions can be daunting. And the task is sometimes exacerbated by strange error messages that you get from the tools. I was tweaking the configuration for logcheck and suddenly started to get this error:
egrep: character class syntax is [[:space:]], not [:space:]
Which is really not providing that much context and therefore very unhelpful. Not to mention that in this case [:space:] may mean any of [:alnum:], [:alpha:], [:digit:], [:space:], [:word:] and others. The error message is exactly the same whatever character class produced the error. So you know there is a problem somewhere but you don’t even know with which class.
The typical problem causing this sort of message is that when you write complex expressions you forget to enclose the class into square brackets. The square brackets are required, for example, for operators like ‘+’. So a correct expression would look like this:
[[:alnum:]]+ [[:digit:]]+
But it is easy to overlook a mistake when you write this:
[:alnum:]+ [:digit:]+
It still kinda looks okay because the square brackets are there but you are missing the extra pair and it is hard to spot. So it may be helpful to look for patterns like ‘:\][?+*]‘ in your code with grep or vim search.
Origin: https://tigr.net/3515/2014/11/03/egrep-character-class-syntax-is-space-not-space/
egrep. It's amazing!
I have a sentence here with words in it.
And I have another sentence here with more words in it.
And another sentence but I'm skipping certain...
And finally this is all I will need to finish this example.
OK. So lets say the sentences above are in a file called blogexample. I only want the lines that contain the words, "skipping" and "finally". How would you grep just those two sentences?
Before, not knowing about egrep, I would cat the file, and then grep for "skipping", then output to a new file, probably call it blogexample2. Then repeat the process for "finally".
It turns out that its possible to do in one command using grep that would look like:
cat blogexample | grep -e "skipping" -e "finally"
But using egrep, it will look more elegant, and save on typing:
cat blogexample | egrep "skipping|finally"
Now, where else can egrep come in handy? How about checking out your Linux OS battery information? Linux doesn't use the OS X command, "ioreg". Instead, try "upower -d" for battery info on your Linux box.
But the upower command outputs lots of information and perhaps you might not want it all. I found that I am interested in:
How much watt hours (Wh) of energy my battery could hold when it was new
How much Wh of energy it can hold now
The current full capacity as a percentage of full capacity when new
Current percentage charged
The keywords to get just the information above are "energy-full" "percentage" and "capacity".
Here's how it looks when you run the one-liner:
me@me-win7:~/Documents$ upower -d | egrep "percentage|capacity|energy-full" energy-full: 38.124 Wh energy-full-design: 47.52 Wh percentage: 98% capacity: 80.2273%
It's nice that I can knock out 2 of the items using the same keywords.
One last example for when egrep can be useful is looking at your ip address information using the ifconfig command.
Sometimes it will suffice to do an ifconfig and grep for "inet" (or "inet addr" if you want to exclude ipv6 addresses). But it also cuts out the interface name and sometimes its nice to have the interface name as well as the ip address.
If you grep for "inet addr" it looks like:
me@me-win7:~/Documents$ ifconfig | grep "inet addr" inet addr:127.0.0.1 Mask:255.0.0.0 inet addr:111.222.11.22 Bcast:111.222.11.1 Mask:255.255.255.0
But if you use egrep, you can get the interface names:
me@me-win7:~/Documents$ ifconfig | egrep "eth0|wlan0|inet addr" eth0 Link encap:Ethernet HWaddr 00:00:cc:dd:99:cc inet addr:127.0.0.1 Mask:255.0.0.0 wlan0 Link encap:Ethernet HWaddr ee:33:dd:22:44:22 inet addr:111.222.11.22 Bcast:111.222.11.1 Mask:255.255.255.0
Use egrep. Save time. Look better.
A quick post on how to find all the configuration variables in Moodle code (2.5.x) and why such a list might be useful. Got a better trick then comment!
Regular expression with egrep
Set word boundaries with \< and \>
Example: egrep -i '\<the\>' myletter.txt List all the lines in myletter.txt containing the word the insensitive of case.
To specify a set or range of characters use braces []
Example: [a9A05] Specify the set { a, 9, A, 0, 5 }
To negate a set or range of characters, use ^ as the first character
Example: [^a9A05] Specify the set of anything but { a, 9, A, 0, 5 }
To specify a range of characters, use -
Example: [a-z] Specify the set of all lowercase letters { a, b, c, d, …, z }
A regular expression may be followed by one of several repetition operators: ? The preceding item is optional and matched at most once. * The preceding item will be matched zero or more times. + The preceding item will be matched one or more times. {n} The preceding item is matched exactly n times. {n,} The preceding item is matched n or more times. {n,m} The preceding item is matched at least n times, but not more than m times.
Two regular expressions may be joined by the infix operator |; the resulting regular expression matches any string matching either subexpression.