This entry focus on filtering sets of character from string or from text file using grep.
Here's a quick usage of parsing and filtering multiple character using grep.
Say we have a sample testfile.txt that contains the following text data.
# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~
1 linux command line
2###########
3$$$$$$$$$$$
this is number 4
5 terminal
~~~~~~~~~~~~~~~~~~~~~~~~~
And we want to grep those lines that contain these three characters #4$
Here's how to quick do the task.
# grep '[:#4$]' testfile.txt
would give you a resulting lines of
~~~~~~~~~~~~~~~~~~~~~~
2###########
3$$$$$$$$$$$
this is number 4
~~~~~~~~~~~~~~~~~~~~~~
As you can see from above results, each lines containta one of the following chatacters:
#
4
$
This is applicable when you need to search for specific set of characters from string or file.
If you wish to grep for multiple set of strings using grep, you read it here.
No comments:
Post a Comment
Thanks for the comment and for peeping into my blogspot. Hope you enjoy your reading them.
If you wish to receive posts updates, you can subscribe directly from this link:
http://feeds.feedburner.com/VertitosBlogspot
using any RSS reader or even Google Reader.
Again, appreciate your site visits.
Cheers then
VeRTiTO
Email: vertito@gmail.com