Command line calculator, bc

September 4th, 2006 mysurface

How to do calculation if I only have command line? If you have BC you can, and you can do a very complicated calculation. To perform calculation, you can type bc and start to type your question, or passing question through pipeline, such as echo “56.8 + 77.7″ | bc Let say you want to [...]

Posted in bc, Calculation, pipeline | Hits: 143137 | 21 Comments »

smart grouping shorten long command line

August 25th, 2006 mysurface

Let say you want to copy certain files from a directory to current directory, which the parent path is long, how the command will looks like? cp /home/foobar/downloads/one /home/foobar/downloads/two….. . So most of the people will change directory to downloads first, then copy those files, such as (Assume the current directory is /home/soomee/downloads ) cd [...]

Posted in curly brackets, Symbol | Hits: 23031 | 4 Comments »

arrange your text nicely with column

August 17th, 2006 mysurface

Try to cat /etc/group, you will find the output text is showing name:x:id: …, which list of groups is separate by : To separate it nicely by columns, you can do that: cat /etc/group | column -t -s”:” Related Postsarray and for loop in awkgrep is always a useful tools to help analyze logs. When [...]

Posted in column, pipeline, Text Manipulation | Hits: 25994 | 1 Comment »

grep as a filter for your raw text based data

August 15th, 2006 mysurface

grep is a very useful and simple tools for a unix user to extract info from text based data files, command output, etc. grep always apply together with pipeline to simplified the data output we obtain to form the information which is presentable. For example, ps aux will shows info about the current running processes. [...]

Posted in cat, Common, grep, pipeline, ps, Text Manipulation | Hits: 37049 | 3 Comments »

log personal message to /var/log/messages

August 14th, 2006 mysurface

To log personal messages to /var/log/messages when you write script, you can use logger simple example: logger i am testing And check the result with tail, it display last 10 line of messages by default tail /var/log/messages To put more info to log file, you can specified the timestamp with scriptname by this logger -t [...]

Posted in Admin, backquote, logger, tail | Hits: 86051 | 14 Comments »

find out the command is from which packages using rpm

August 5th, 2006 mysurface

rpm is a common package manager for red hat, fedora, centos distro, to find out the command is from which package, you can using rpm -qf, let say you wanna find out “host” is from which package. rpm -qf `which host` #output: bind-utils-9.3.2-20.FC5 Take care of the symbol (`) , it is not single quote. [...]

Posted in Admin, backquote, rpm | Hits: 22385 | 2 Comments »