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
Wirklich nützlicher Text, es gibt nicht oft so eine konkrete Herangehensweise.
Ich selbst sammle Ideen für eine frische Einrichtung und komme sicher noch einmal hierher.
Danke.
Here is my homepage; Blair
hey there and thank you for your info – I have certainly picked up
something new from right here. I did however expertise some technical issues using this website, as I experienced to
reload the site lots of times previous to I could get it to load correctly.
I had been wondering if your web host is OK? Not that I am
complaining, but slow loading instances times will often affect your placement in google and
could damage your quality score if advertising and marketing with Adwords.
Well I’m adding this RSS to my e-mail and could look out for much more of your respective fascinating content.
Make sure you update this again soon.
It’s going to be ending of mine day, except before ending I am reading this enormous post to increase
my know-how.
Přesně tohle jsem hledala, bez povrchních tipů. Oceňuji konkrétní postupy,
které zvládne i začátečník. Super práce.
My site: http://pymewiki.oceanicsa.com/index.php/user:stellashively63
Přesně tohle jsem hledal, bez povrchních tipů.
Oceňuji jasná doporučení, které mají hlavu a patu.
Super práce.
Also visit my blog :: Catherine
Good way of describing, and pleasant article to obtain data about my
presentation focus, which i am going to present in academy.
Konečně normální rada, bez zbytečných řečí.
Cením si konkrétní postupy, které zvládne i začátečník.
Moc díky.
My blog post :: Gratisafhalen.be
Amid the latest Portsmouth news, pizza in portsmouth, community events are
influencing the civic landscape. People are enthusiastically participating in multiple activities that bring the town together.
For newest news you have to go to see the web and on world-wide-web I found this website
as a finest website for most up-to-date updates.
I every time spent my half an hour to read this blog’s posts
daily along with a mug of coffee.
live casino neosurf
My web site: neue fruit slots
I know this website presents quality dependent content and
additional material, is there any other site which gives these information in quality?
Dobrý článek, málokdy se vidí obsah bez zbytečné omáčky.
Sám zařizuji byt v paneláku a pár věcí si vezmu k srdci.
Díky.
My webpage :: dokončení interiéru
Witajcie, natknąłem się na ten temat i chcę powiedzieć, że temat jest ograny porządnie. Też stoję przed takim wyborem i przydały mi się te wskazówki. Dzięki za wszystkie podpowiedzi.
Feel free to surf to my web site … https://Gratisafhalen.be/author/brockbostoc/
Nazdar, narazil jsem na tohle téma a vidím, že je o čem číst. Taky stojím před stejným rozhodnutím a sbírám všechno, co se dá. Díky za všechny příspěvky.
Visit my web blog https://Suachuamaybienap.com/index.php/Ruka_bo%C5%BE%C3%AD:_pravidlo,_kter%C3%A9_fotbal_zm%C4%9Bnilo_v%C3%ADc,_ne%C5%BE_kdokoli_%C4%8Dekal
Aufstell Pool Set rund holz oval groß 150 tief viel Auswahl rund
um freistehende Pools zum einbau aufbau einlassen Montage zum aufstellen im Garten Komplettset
After looking at a handful of the blog articles
on your site, I honestly appreciate your technique of writing a blog.
I saved it to my bookmark webpage list and will be checking
back soon. Please check out my web site too and tell me your opinion.
Feel free to surf to my blog post; https://perte-cheveux.top/
Ahoj, procházel jsem diskuze o bydlení a vidím, že je o čem číst. Sám právě řeším podobnou situaci a sbírám všechno, co se dá. Kdyby měl někdo zkušenosti s tímhle tématem, rád si počtu..
Also visit my webpage; https://Wavedream.wiki/index.php/Z%C3%A1v%C4%9Bsy_lad%C3%ADte_a%C5%BE_nakonec,_a_to_je_chyba,_kter%C3%A1_zabije_%C3%BAtulnost
Cześć, trafiłem tu szukając informacji o remoncie i widzę, że temat jest ograny porządnie. Też stoję przed takim wyborem i szukam sprawdzonych rozwiązań. Dorzucam się do dyskusji.
Have a look at my blog … https://www.repecho.com/author/deewannemak/
online casino mit lizenz saarland
My web page :: bingo App Echtgeld
Toller Beitrag, es gibt nicht oft Inhalt ohne unnötiges Geschwafel.
Ich selbst bin gerade mitten in der Renovierung und komme sicher noch einmal hierher.
Danke.
Feel free to visit my blog post :: https://Www.88M2.Com
Trafiłam tu szukając informacji o remoncie i nie żałuję.
Najbardziej przydał mi się kawałek o kosztach.
Zapisuję sobie.
Feel free to visit my webpage … Jacelyn