Programming :: Bash : Searching For Info And Changing The Color Of Keywords In The Results?

May 5, 2011

(bare with me as I am sort of new with scripting) I am trying to figure out how to run a script that does a basic chkconfig and to get only those services that are running, but changing the color of "on" to red in my output file. Here is what I am working with so far:

Quote:

#/bin/bash
RED=$(tput setaf 1)
BLK=$(tput setaf 0)

[code]....

*I had to substitute a "-" and <colon_symbol> for ":" in front of the on's, because the forum thought they were smiley faces (i.e. n) how to make the "on" to be red while the rest of everything remains in black text. I have been trying to read up on sed and awk, but it is still pretty much a mystery to me right now. There will be other things in the output file that I wouldn't want a rogue "on" to be in red, so just the instances of "on" in that one chkconfig return.

View 4 Replies


ADVERTISEMENT

Programming :: Changing Color Of Output From Bash Script?

Apr 22, 2010

I am writing a bash script that utilizes the output of another script (which I will refer to as script#2.) Script#2 is not owned by me, I cannot modify it. All of the output from script#2 is blue, which makes it difficult for me to read.

I would like to have the output of it changed to grey. Is there a way I can do that in my script? A command I can pipe the output to?

Edit: One other question related to this. I put a trap function in my script that works well. Script#2 essentially runs a tail -f. When I ctrl+c to stop it, it stops script#2 and never calls the trap in my script. Is there any way I can work around that?

View 3 Replies View Related

Red Hat :: Changing Bash Color Prompt?

Mar 24, 2010

I was attempting to change the bash shell color prompt on my RHEL / CentOS 5 server. When I login as my user account on my server I can see my 'PS1':

Code:
[carlos@srv1 ~]$ echo $PS1
[u@h W]$

I want to change my PS1 to:

PS1='[e[1;32m][u@h W]$[e[0m] '

When I look in ~/.bashrc, I don't see my 'PS1' line so I am confused and wondering how I do this on RHEL / CentOS systems.

View 2 Replies View Related

Programming :: Bash Function For Searching Files ?

Jun 15, 2011

I'm making a small script for searching and doing some operations with photos, but I'm kinda stuck on this little function:

Code:

function findallformat {
prefix=""
if [ $1 = -pre ] then

[code]....

That function should find for every file with a certain type; and you can specify a prefix using a "-pre" followed by the prefix that you want to search. The format should be "stackable", so you can use as many types that you want, without repeating the same function on the code.

Example: findallformat -pre IMG_ .JPG .CR2 #That should search files that start with "IMG_" and finishes with .JPG and .CR2. My problem it's that, when I try to use it on the script, it says "bash: syntax error near `token' unexpected `}'"

View 4 Replies View Related

Programming :: Bash - Searching Strings For Array Elements?

Apr 30, 2010

...and returning the index of the found element in its array.

I have:

for ((i=0; i < ${#array1[@]}; i++)); do
# Read each line of the file test
if [[ $(eval "sed -n '$(($i+1))'p test") == *${array2[0]}* ]]
stuff

I want to find the index of the found substring in array2 and only if it isn't found, move on to the next element of array2. I don't know the size of array2 so that [0] has just got to go.

View 14 Replies View Related

Programming :: Looping Over Mysql Query Results In Bash?

Sep 15, 2010

I am querying a single string column in a table. The string values have spaces in them. I want to loop over each value in bash. I set IFS to split lists on newlines instead of spaces. When I try this, it is splitting the list of results on the actual character 'n', not the newline ''.

DATA=`mysql -u root -ppassword --silent 'SELECT name FROM table_a;'`
IFS=$'
'
for i in $DATA; do
echo "item = $i"

[Code]....

View 5 Replies View Related

Programming :: Get Pixel Color From Screen In Bash Script?

Nov 25, 2010

I would like to get the pixel color from screen at (320,240) and if the color = 0xFFFFFFFF , i would like to execute a command.

View 3 Replies View Related

Programming :: Easier Way To Color Text In Perl Like BASH?

Apr 8, 2010

I've been trying to figure out a way to more easily color text in Perl like I do on Bash on a Linux box. In bash, what I'll do is set color variables up to equal the escape sequence, then echo out with escape seqeunces to print it exactly how I want it. Typically I'll want a character or a word in a different color, not the whole line. For example

echo -n -e "My face is turning ${RED}red${UNCOLOR} like a lobster." In Perl with the term::ANSIColor module, it seems to just do a line. Am I being dense? Is there a way that I can do it like I do it in BASH that's fairly easy to read after the fact?

View 11 Replies View Related

General :: Custom Syntax Highlighting In Bash Shell - Using Keywords

Apr 25, 2011

I know it's possible to change the $ user@hostname colors, but is it possible to color different things? Could I make all numbers/integers a certain color. Or set certain keywords to be bold?

View 1 Replies View Related

Slackware :: Clear The Highlighted Results After Searching In Elvis And Other Text Viewer Programs Such As Less?

Apr 4, 2010

how do you clear the highlighted results after searching in elvis and other text viewer programs such as less?Also I know it's been mentioned before, but why does pat prefer elvis to vim? Just a personal preference?

View 9 Replies View Related

Programming :: Running More Than One Script In A Bash Script And Piping Results To SSH?

Jun 8, 2010

how to set the subject of this up.. but here is what I am trying to accomplish (please keep in mine, this is only my first month playing with ANY Linux programming): My shared web host limits running 2 CRONS or 2 SSH sessions at one time. I need to run more than that.. So, my solution is to run what I need on my home computer, and then push all the results via SSH to my web server.

To keep things timed, I am trying to call 4 bash scripts from inside of 1 bash script... Each bash script has variables I need to export out to the remote (web) server. Being that I can only run 2 SSH or 2 CRON sessions on the remote, it wouldn't do me any good to open up CRON or SSH remotely or locally - either way I'm maxing out. That is why I would like to call 1 final script that takes the output of the 4 bash scripts and does the job.

Main bash calls via CRON every 30 minutes:

Code: ./script_1 &
./script_2 &
./script_3 &
./script_4 &

[code]....

I need to scp the file saved by wget to the remote server. I also need to pass the SQL statement generated in each script as a command in SSH. I'm lost how to get the info from "script_x" into a string that can be used to SSH - and doing this all inside of ONE SSH command. Would I store the SQL strings in a file and call that in the SSH command line?

If so, what is the command to make sure the variable output in the "script_#" file is sent to a file? Can I call the variable from the main Bash Script? Now - the good news is, I can SSH from my local machine to the remote one.That is about as far as I got.Again - I am so new to this that my ears are still wet. This has been something I have been working on for a while, and I'm just lost at this point.

View 2 Replies View Related

Programming :: How To Parse And Modify Keywords Using Shell Script?

Apr 14, 2011

There is a file with that format of each models' information.I don't think that's good format, but I cannot change that format. I needed to modify the model name, 'model = xxx' as 'model = abc'.And I don't know how to parse and modify 'model = iii' and 'model = ddd'.The only clue to parse 'model = ddd' is the second 'model = ' after the second 'system information'. But how to parse the second keyword?Is it possible with 'sed'?I sometimes have to modify the information of the file.using shell script if possible.Python is ok. (Shell script is better for me.)

View 15 Replies View Related

Programming :: Bash Script For Automatic Viewport Changing And Other WM Stuff (works With Compiz)?

Oct 18, 2010

I had to make for work a collectd based network monitoring system which displays data for each server in a fullscreen conky on different compiz viewports. I have to switch viewports automatically when the machine isn't operated (sorta screensaver) and also if i had to call attention in the case something bad happens, autoswitching should stop and the relevant viewport be showed up.This requires an interface to talk dynamically to the WM, which i've implemented in bash with support of the widely available "wmctrl" program.

Code:
http://paste2.org/p/1177045
Code:

[code]...

View 8 Replies View Related

Programming :: Changing A Line In A Config File While Installing The Program Using Bash Script

Jul 22, 2011

I am trying to write a bash script that installs a program fully automated for me. I am stuck at the one part where i need to change a line in one config file. I have tried various syntax for sed and none have worked. Maybe someone can suggest how to go about this. Since the line appears in the middle of the file, I can't use echo or cat. Also the file will be diffrent lengths depending on the install.

The line I need changed is:

I need that changed to:

the last syntax i tried is:

Yes this is for PNP4Nagios on centos 5.6 64bit. If i can get this figured out. I will be willing to post the whole thing for others to use. it will be used to install PNP after a working nagios install is done.

View 11 Replies View Related

Programming :: Favorite 256-color Vim Color Scheme

Feb 25, 2011

What is your favorite 256-color color scheme for vim?

View 6 Replies View Related

Software :: Searching Within A File Using Bash?

Jul 22, 2009

i get the desired result with

find . -name "*" | xargs grep -i "*searchPattern*"

---but not with

find . -name "*" | grep -i "*searchPattern*"

why this difference?

View 6 Replies View Related

Ubuntu :: Changing GPU Clock Speeds Results In Black Screen?

Sep 13, 2010

I've recently done a clean install from Karmic to Lucid, everything went well first time, although I noticed that my GPU performance seemed to drop. It wasn't amazing to begin with being an older AGP card (nvidia 6800GT), but it was enough of a drop to make me look for a solution.

I thought maybe the drivers in Lucid were to blame so I recently added the ubuntu-x-swat PPA

[URL]

to get the most up to date drivers.

Performance didn't go up, so I tried the 173 version of the drivers to see if that would help, but I had no luck.

Today I'm pretty sure I downloaded an update from the above PPA and since then every time I change the clock speeds (via the Coolbits option within nvidia-settings) on my card I get a black screen, there is no response from any input device and I have to hold the power button to turn off the PC.

I want to know if there is anyway to check recent packages I've downloaded, and also if anyone could shed some light as to why changing the clock speeds of the card would result in a black screen and no response from the keyboard or mouse.

I'd also like to point out, that I've been changing the clock speeds of the card since I first installed Karmic with no problem. Additionally before I downloaded today's updates, even with the new packages from the above PPA changing the clock speeds worked perfectly. It seems that something I downloaded is to blame.

View 2 Replies View Related

Ubuntu :: Changing Task Bar Color?

Jun 25, 2011

Just upgraded to Lubuntu 11.04. Holy mother of God, the default theme is an atrocity. It looks like somebody puked blue on my desktop. I changed the theme but cant figure out how to change the color of the task bar on the bottom of the screen.

(On a completely unrelated note, Firefox now thinks Im British and wants to change color to colour....weird.)

View 4 Replies View Related

Fedora :: Changing Color Of Title Bar Of Windows In F15?

May 26, 2011

I'm playing with the system now and I have some questions. I wasn't able to find answers to some of them on this forum or the net.

My first question doesn't necessarily lighten me as someone with deep personality: how do I tweak the color of the title bars of the active and non-active windows in Gnome 3?

View 4 Replies View Related

OpenSUSE Hardware :: Changing Color Depth In 11.4 KDE?

Apr 5, 2011

1. Identify what my current color depth setting are? (default opensuse 11.4 KDE install)

2. How do I change it? Am assuming it is set to 32bit now, would like to set it to 24.

The reason is my little netbook really burns up when i play a video.. acer aspire one and one of the reason why I installed linux over windows 7 was that I wanted my laptop to run faster ... apart from the fact that I would have installed suse anyways!!

View 2 Replies View Related

Ubuntu :: Changing The Color Of Terminal Cursor?

Feb 2, 2010

Is there a way to change the color of the blinking cursor without changing the color of the text?

Or, if this cannot be done in gnome-terminal, is it possible in another terminal (yakuake, etc) ?

View 4 Replies View Related

Ubuntu :: Changing The Window Border Color?

Mar 21, 2010

I have been struggling to change the border color of the windows on Ubuntu without actually changing the theme (e.g., Keeping the "Human" theme, but having the frame borders be a different color than orange.) I have searched Google for some help, but found nothing that works. I have gone to System > Preferences > Appearance and set the 'Selected Items' color [URL] but to no avail. Only the controls changed color, not the window borders.

View 8 Replies View Related

Ubuntu :: Changing The Color Depth From Whatever It Is Now To 24bit?

Dec 29, 2010

I am trying to create a media server, and I decided to try out Ubuntu, but I'm having trouble figuring this out. I have taken a suggestion that I got from another forum, but it did not work.

I'm using version 10.4 and I have to get it to at least 24 bit so I can run XBMC. I have a friend that works for red hat and he said I needed to find the restricted driver or something, but I can't find it, and he doesn't know where it might be on Ubuntu. So, does anyone know how I can change my color depth to 24bit?

View 1 Replies View Related

General :: Changing Cursor Color In Gedit?

Dec 31, 2010

I am working with scientific linux 4 with specification Linux localhost.localdomain 2.6.9-67.EL.cernsmp #1 SMP Wed Nov 21 16:22:33 CET 2007 i686 i686 i386 GNU/Linux. How can I change my cursor color from black to green in gedit

View 5 Replies View Related

Software :: Changing Font Color In CSS File

Apr 27, 2011

I am working with a template.css file, and I want to change the color of the font in part of the header from black to blue. Is there syntax that can be inserted into the file to accomplish this?

View 14 Replies View Related

Red Hat :: Changing Cursor Color In Gedit In Gnome

Jan 4, 2011

I am using Scientific linux 4 cern with the following configuration: Linux localhost.localdomain 2.6.9-67.EL.cernsmp #1 SMP Wed Nov 21 16:22:33 CET 2007 i686 i686 i386 GNU/Linux I want to change the cursor color from black to green in gedit in GNOME. How can I do this? Chnging fomt color doesnot work.

View 1 Replies View Related

Ubuntu Security :: Changing Hardware ID Info?

Aug 31, 2010

Each computer has certain hardware that has its own ID...My understanding is that this info can be used to identify you.

Is there a way to either permanently change the ID values of that hardware in the bios or hardware, or at least a way to alter what you transmit to websites when that info is recorded?

What information is being transmitted as I post right now?

Lately I have become very concerned about data mining. I do not want corporations to be saving my web browsing behavior so they can market me products, and I do not want that same info being given to the government either. I have an expectation of privacy on the internet.

View 2 Replies View Related

General :: SU Results In Cannot Execute Bash

Feb 13, 2011

SU results in Cannot execute bash: No such file or directory.

View 1 Replies View Related

Ubuntu :: HP Envy 14 - Boot Into Live CD Without Changing Any Parameters Results In A Black Screen

Feb 8, 2011

I own an HP Envy 14 [url]. Letting Ubuntu (or any Linux) attempt to boot into a Live CD without changing any parameters results in a black screen, but with everything else working (for Ubuntu, that means the login sound is played). I've discovered that putting nomodeset in the kernel line will allow me to get so far as a command line, but I can't startx from here (I get "Screen(s) found, but none have a usable configuration."). I think my issues have something to do with the dual/switchable graphics in my laptop.

View 7 Replies View Related

Ubuntu :: Changing Gtk Slider Color On Scrollbar Hover?

Sep 12, 2010

I'm using the Human-Clearlooks theme on Lucid (Gnome) with compiz/nvidia driver.

I'd like to have the scrollbar sliders a bit (only) more visible. Ideally, it would switch orange when I hover it with the mouse, and stay gray otherwise. This is because my screen is quite large, and when the slider is small I find it difficult to find its position.

1. I opened the gtkrc file and set colorize_scrollbar = TRUE in the engine "clearlooks" block. Now the scrollbar sliders are always orange. I'd really like to have them orange only on hover.

2. There is a "clearlooks-scrollbar" style. I tried adding (fg|bg|base|text)[] in it. I found that:A. fg[] is for the arrow within the top and bottom square boxes

B. bg[NORMAL] and bg[INSENSITIVE] define the color of the box containing the arrow (or if colorize_scrollbar = FALSE, the color of the whole scrollbar, including the square boxes and the slider itself)

C. bg[PRELIGHT] is the color of the box containing the arrow when hovered

D. bg[SELECTED] is the color of the slider (permanent)As it was most unsuccessful, I tried to force the murrine engine for the scrollbars only. Now with bg[PRELIGHT] = @selected_bg_color I get something fairly close to my expectations.

Only I'd like the bar to be pre-lighted not only when the mouse is over the slider, but as soon as it is over the scrollbar. Here I must say I'm at loss, and I really can't find how to do it.

how to change the slider color on scrollbar hover?

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved