Colourful grep on aix.
Linux implements a decent version of grep and highlights the search term using colour. Whilst AIX terminals can support colour (if your term session supports it) with escape codes I have not seen any way of making grep or egrep etc colourful.
On linux you simply add the parameter –color=auto such as
grep --color=auto SearchTerm {files}
Well as I couldn’t find anything on google I decided to implement something. And this is what I came up with. However the one bug I didn’t manage to resolve was If searching case insensitively the highlighting will only find the correct case. As sed does not support case insensitively this is a problem to solve. If nawk or gawk is installed, they do support it with the -i parameter.
#!/bin/ksh
#************************************************************************
# *
# Module Name : grepc.sh *
# Author : Dave Jarman +
# *
# Edit Record (most recent edit at top of list) *
# Date By CF Comments *
# --------- --- ---- --------------------------------------- *
# 5-Apr-12 DCJ i Use ampersand in sed search results as
# matched string to better handle regular
# expressions (thanks Zolo).
# 20-Sep-11 DCJ New file *
#************************************************************************
#
# Executes grep but with the escape codes to colourise the output.
#
# Known Bugs:
# If searching case insensitively the highlighting will only find the
# correct case. As sed does not support case insensitively this is a problem
# to solve. If nawk or gawk is installed, they do support it with the -i
# parameter.
#
# Other colours are available. Use the following lines.
# Blue echo "s/$QRY/\033[1;34m$QRY\033[0m/g" > $TMP/$$.sed
# Light blue echo "s/$QRY/\033[1;36m$QRY\033[0m/g" > $TMP/$$.sed
# Inverse blue echo "s/$QRY/\033[44;37m$QRY\033[0m/g" > $TMP/$$.sed
# Red echo "s/$QRY/\033[0;31m$QRY\033[0m/g" > $TMP/$$.sed
#************************************************************************
# Check for any options and save them
OPT=
while [[ $1 = [-+]?* ]]
do
OPT="$OPT $1"
shift
done
#
# Get the search string.
QRY=$1
shift
#
# Create a sed script to subsitiute for the appropriate colour.
# Show the search term in Blue
# echo "s/$QRY/\033[1;34m$QRY\033[0m/g" > $TMP/$$.sed
echo "s/$QRY/\033[1;34m&\033[0m/g" > $TMP/$$.sed
# echo /usr/bin/grep $OPT "$QRY" $* "|" sed -u -f $TMP/$$.sed
/usr/bin/grep $OPT "$QRY" $* | sed -f $TMP/$$.sed
#
# Clean up the tmp file *
rm $TMP/$$.sed
#
# Finish
exit 0
This is my first time pay a quick visit at here and i
am genuinely impressed to read everthing at single place.
Also visit my page AW8
самые точные прогнозы на хоккей самые точные прогнозы на хоккей .
Helpful information. Fortunate me I found your site accidentally, and I’m stunned
why this twist of fate did not took place in advance! I bookmarked it.
We are a group of volunteers and opening a new scheme in our community.
Your site provided us with valuable information to work
on. You’ve done an impressive job and our whole community will be grateful to you.
The live baccarat game feels so luxe!
Also visit my homepage – savaspin
Hmm is anyone else experiencing problems with the pictures on this blog loading?
I’m trying to figure out if its a problem on my end or if it’s the blog.
Any suggestions would be greatly appreciated.
бк мостбет бк мостбет
each time i used to read smaller posts which also clear their motive, and that is
also happening with this article which I am reading now.
Aqua Sculpt sounds amazing! ✨ The idea of using
a water-based approach to help shape the body and support fat loss is really unique.
I like that it’s designed to be gentle yet effective, making it a great
option for people who want results without extreme methods.
мостбет андроид http://mostbet11069.ru/
Thanks for the marvelous posting! I really enjoyed reading
it, you will be a great author. I will always bookmark your blog and
may come back later in life. I want to encourage one to continue
your great writing, have a nice evening!
Hmm it appears like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog.
I as well am an aspiring blog writer but I’m still new to everything.
Do you have any recommendations for beginner blog writers?
I’d definitely appreciate it.
Tremendous things here. I am very satisfied to look your post.
Thank you a lot and I’m looking ahead to contact you. Will you kindly drop me a mail?
Its not my first time to pay a visit this web
site, i am browsing this website dailly and take fastidious information from here all the time.
Good way of explaining, and fastidious article
to obtain facts regarding my presentation subject, which i am going to deliver in college.
I’m gone to convey my little brother, that he should also pay a visit this webpage on regular basis to get updated from
hottest information.
кашпо с автополивом кашпо с автополивом .
Link exchange is nothing else however it is just placing the other person’s weblog link on your page
at proper place and other person will also do
similar for you.
Yes! Finally something about akhuwat.
www mostbet com www mostbet com
I’m gone to convey my little brother, that he should
also go to see this website on regular basis to
get updated from most recent reports.
I’ve been surfing online more than 4 hours today, yet I never found any interesting article like yours.
It is pretty worth enough for me. In my opinion, if all site owners and bloggers made
good content as you did, the internet will be a lot more useful than ever before.
Definitely believe that which you stated. Your favorite reason appeared
to be at the net the simplest factor to understand of. I say to you, I definitely get
irked even as people consider issues that they plainly do not understand about.
You managed to hit the nail upon the highest as
well as outlined out the entire thing with no need side effect ,
other people could take a signal. Will probably be back
to get more. Thank you
цветочные горшки с поливом https://www.kashpo-s-avtopolivom-kazan.ru .
I really like your blog.. very nice colors & theme.
Did you design this website yourself or did you hire someone
to do it for you? Plz respond as I’m looking to design my own blog and would like to know
where u got this from. cheers
I believe this is among the such a lot vital info for me.
And i am glad reading your article. However want to statement on few normal issues, The site style is wonderful, the
articles is in point of fact excellent : D. Good job, cheers
Hi to every body, it’s my first visit of this blog; this blog includes awesome and truly excellent material for visitors.
Excellent goods from you, man. I have understand your stuff previous to and you’re just too great.
I actually like what you have acquired here, certainly like what
you are stating and the way in which you say it. You make it entertaining and you still care for to keep it sensible.
I can not wait to read much more from you. This is actually a great web site.
mostbet личный кабинет https://www.mostbet11075.ru
компьютерные прогнозы на футбол компьютерные прогнозы на футбол .
First off I want to say awesome blog! I had a quick question which I’d like to ask
if you don’t mind. I was interested to know how you center yourself and clear
your thoughts before writing. I’ve had difficulty clearing my thoughts in getting my thoughts out there.
I do enjoy writing but it just seems like
the first 10 to 15 minutes are usually wasted simply just trying to figure out how to
begin. Any recommendations or tips? Appreciate it!
Everything is very open with a very clear clarification of the issues.
It was really informative. Your site is very useful.
Thank you for sharing!
canada drugs without prescription
I am really impressed with your writing skills as well as with the layout on your weblog.
Is this a paid theme or did you customize it yourself?
Anyway keep up the nice quality writing, it’s rare
to see a great blog like this one today.
прогнозы на хоккей лайв http://luchshie-prognozy-na-khokkej13.ru/ .
I really like reading a post that can make people think.
Also, many thanks for allowing for me to comment!
It’s remarkable in favor of me to have a web site, which is good designed
for my experience. thanks admin
купить диплом в кургане занесением в реестр купить диплом в кургане занесением в реестр .
Whoa! This blog looks just like my old one! It’s
on a completely different topic but it has pretty much the same layout and design. Wonderful choice of colors!
Can I simply say what a comfort to find somebody who truly understands
what they’re discussing on the internet. You actually realize
how to bring an issue to light and make it important.
More and more people must check this out and understand this
side of the story. I can’t believe you aren’t more popular since you definitely have the gift.
top mexican pharmacies
This is a topic that’s near to my heart… Take
care! Where are your contact details though?
This is the right blog for everyone who really wants to find
out about this topic. You realize a whole lot its almost tough to argue with you (not that
I actually will need to…HaHa). You certainly put a fresh spin on a topic which has been discussed for many
years. Great stuff, just great!
Very nice post. I simply stumbled upon your weblog and wished to
say that I have really loved surfing around your blog posts.
After all I will be subscribing for your rss feed and I hope you write
again soon!
reputable canadian online pharmacies
I’m amazed, I have to admit. Rarely do I come across a blog
that’s equally educative and engaging, and let me tell you,
you have hit the nail on the head. The problem is something which
not enough folks are speaking intelligently about. Now i’m very happy that I found this during my search for something
concerning this.
Excellent information about relocation services! I recently changed locations
last month, I can confirm that selecting the perfect moving company
is crucial. Thanks for sharing these helpful recommendations.
mostbet bet http://www.mostbet11067.ru
It’s amazing to pay a visit this web page and reading the views of all colleagues on the topic of this paragraph, while I
am also zealous of getting experience.
list of reputable canadian pharmacies