My script prints lines in which the entire line may be colored, and portions may also be colored. e.g.
Consider this to be one line:
$redsome text in red $yellow abcd $end_yellow red text 1234 $blue some text $end_blue more red text $end_red
So using sed, I may based on condition 1, color the entire line red, and then based on other patterns, color portions in various colors.
I am aware of how to start coloring. However, the command to end coloring, ends *all* coloring, instead of switching off the existing color. So i cannot embed colors within other colors.
I've searched high and low but can't find anything -- any ideas.
If some patterns are found, only those patterns are printed in a color.
For other patterns, the entire line is printed in a color.
So you can have a red line with some words in blue or white etc.
However, since the code for closing a color closes all colors, so the rest of the line comes uncolored.
\033[0m - removes all color attributes. I am looking for something that will only switch off a given color, so the rest of the line can continue in the old color.
Its a bit like:
$red textaaa $green textggg $end_green textbbb textcc $end_red
I don't know of a way to turn off specific colors.
But I've got this to work on my dtterm (hp-ux using posix shell)
You need the parenthesis to group the assignment to DEF and the sed statement into the same STDIN.
Basically, by setting the variable DEF on the fly, you can create the default color for the whole line. Then instead of turning yellow "OFF" after the word 'is' you just turn red back on with DEF.
This works for me, hopefully I didn't put a typo in. ;-)
---------- Post updated at 05:44 PM ---------- Previous update was at 05:17 PM ----------
Actually, further testing proved it didn't work I had DEF set in my environment, and when I unset it, I got spurious results, however the followig did work:
I put the assignment to DEF and all seds into the same process using multiple -e's to separate out the sed patterns, and printing only on the last pattern of the line.
Hi All,
Can we have colour the matched pattern with any color using unix command? For example I have a very length line a file and I'm applying grep on that file.
grep "matched pattern" filename.txt
My output is like below,
...........matched... (2 Replies)
Hi all,
is there anyone good at bash who will help me?
I need to use syntax ${string/pattern/replacement}
The problematic part where I am stuck is:
#!bin/bash
text="A cat is on a mat."
exp="cat"
newexp="SOMECODEcatSOMECODE"
newtext=${${text}/${exp}/${newexp}}
== > ERROR "wrong... (4 Replies)
picked this up from another thread.
echo 1st_file.csv; nawk -F, 'NR==FNR{a++;next} a{b++}
END{for(i in b){if(b-1&&a!=b){print i";\t\t"b}else{print "NEW:"i";\t\t"b} } }' OFS=, 1st_file.csv *.csv | sort -r
i need to use the above but with a slight modification..
1.compare against 3 month... (25 Replies)
hey... i had a big problem with my professor
i have 3 simple archives
in.txt -> had all timestamps of users logon (100lines)
ex. 111111
222222
333333
out.txt -> had all timestamps of users logof (100lines)
ex. 111113
222225
333332
commands.txt... (9 Replies)
How to I put my find command string into a script. It is currently to long to be entered manually at command line.
for FNAME in `find /unixsxxx/interface/x.x/xxxxxx -type f \( -name '*.KSH' -o -name '*.sh' -o -name '*.sql' -o -name '*.ksh' \) -exec grep -il xxx.xxx.xxx.xxx {} \;`; do C=`grep -c... (5 Replies)
Default shell is /usr/bin/zsh
Script will be running #!/bin/bash
Need to pull information from database while using other scripts already made (not by me).
Ok, so i need a script pulling certain information about a customer's router interfaces.
I am using a ROUTER-DNS-NAME as variable $1
I... (3 Replies)
Hi,
i am using VIM editor through Putty. By the option of Syntax on in .vimrc file i am able to see syntax colors in .c and .cpp files but not in the files with .pc extension.
How can this be done?
:confused: (2 Replies)