If you want to change background color or whatever other settings of one application under X windows, for example, xdvi, you could set it in your file: ~/.Xdefaults by
xdvi*background: white
xdvi*foreground: black
.
Note: your changes will be starting after you log out and in.
Monday, April 20, 2009
Linux: how to change background color of xdvi
ROOT: how to set TGraph Xaxis range.
It seems that I cannot set the x-axis range of TGraph by
graph->GetXaxis()->SetRangeUser(0,1);
. I have to use
graph->GetXaxis()->SetLimits(0,1);
to do this task. But the former way is working for y-axis.
Thursday, April 9, 2009
Linux:shell:BASH: How to delete one line by sed
If you want to delete one line containing one word "ThisWord" by sed, then you can do in the way:
sed -i "/ThisWord/d" YourTextFile.txt
Note, here '-i' is to delete it from the original file. Without it, sed only prints the file on screen. So before using '-i', make sure you are doing correct things.
Thursday, December 18, 2008
Linux:shell:Bash: How to change color of your shell printout

You could use 'echo -e' to change your printout text and background color by some color variables. One of the easiest ways to use them is to define shell variable, for example, define those variables in your shell script:
red='\e[0;31m'
RED='\e[1;31m'
blue='\e[0;34m'
BLUE='\e[1;34m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
NC='\e[0m' # No Color
. '\e[0;36m': 0's place is the color of background (0, no effect, 1, bold, 4, underline) and 36 is the text color. You also can change background colors due to color values in the color table. For example, '\e[41;34m' changes background color to red and text color to blue.
How to print?
echo -e "$red These texts are in red$NC" #you must use '-e' to enable interpretation of the backslash-escaped characters, see echo's help.
or if you want to use it in 'printf':
printf "%s\n" "`echo -e $red`These texts are in red`echo -e $NC`"
There is a table of color values attached (this table is from the link). You can find color values what you want.
Sunday, November 23, 2008
linux:shell: /bin/tar: Argument list too long
When you create a tar archive and have an error: /bin/tar: Argument list too long, then you could try an argument of tar:
-T or --files-from=F
(which allows you to get names to extract or create from file F).
Wednesday, November 12, 2008
linux:shell: broken 'while' loop
When I do a while loop in which there is a command 'ssh', the while loop just goes only one iteration and quits. The problem is from 'ssh' read stdin so that 'while' cannot read anymore and stop afterwards, for example,
while read CompName
do
ssh $CompName 'ls'
echo "Done"
done <>
In the example, only one iteration is conducted (including the echo line). The solutions are provided by google searching. One is general one, I think. 1) Redirect ssh stdin by
< /dev/null ssh $CompName 'ls'
2) ssh-specified trick: use '-n':
ssh -n $CompName 'ls'
Saturday, November 8, 2008
linux:shell:bash:grep: multi-grep
If I want to search multi words by grep, I could do in the way:
egrep "a|b|c|d" my_input_file.txt
then egrep will help you to search OR of a, b, c and d. If searching for AND of multi-words, you can do by pipe:
grep a my_input_file.txt |grep b |grep c |grep d
. However, sometimes, it is not so easy to use pipe in one line for the above usage. You can always build string of the command first and evaluate it. For example,
cmd="grep $var1 my_input_file.txt|grep $var2"
...
cmd="$cmd |grep $var3"
...
eval $cmd
