Thursday, August 13, 2009

linux:command:pdf: a useful tool

In linux, there is a very useful PDF tool called pdftk

http://www.accesspdf.com/pdftk/

Thursday, July 2, 2009

Java:Compile Errors

When I try to install a java program (JaxoDraw) by ant that draws Feynman diagram, I met some errors with my laptop settings. Here are 3 errors that printed on the screen:

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.5.0-gcj-4.2-1.5.0.0/lib/tools.jar

BUILD FAILED: /work/JaxoDraw-2.0-0/build.xml:xxx:
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
/work/JaxoDraw-2.0-0/build.xml:191: Error starting modern compiler


My solution and checking are:
1. I do not have jdk installed. So I installed it first.
2. Set JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.07/" (which is one java location)
3. compile by ant -lib /usr/lib/jvm/java-6-sun-1.6.0.07/lib/tools.jar (maybe, -lib ... won't be needed any more, I don't know)

Wednesday, July 1, 2009

Linux:Shell:Bash: how to search slash or backslash by sed

It is tricky to search (or replace) signs slash '\' or backslash '/' by sed. By searching internet, I found 2 approaches:

1. Put the command line of sed to a file called my.sed:

/D\\O/p

(this will print a line containing 'D\O')

2. Another way is to use single quote instead of double one in your shell command line:

sed -n '/D\\O/ p' myfile.txt

(-n is prevent from printing)

Monday, April 20, 2009

Linux: how to change background color of xdvi

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.

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.

Locations of visitors to this page