Live Chat!

Split screen console terminal ~ Terminator

1 votos Vota!!

January 3rd, 2010 mysurface

Sometimes, you may have many logs to trace at once, you may need to copy and paste text from files to files, and tabbed terminal is just not convenient enough.
So, you hope for a terminal that allows you to split your console screen into either horizontal or vertical flexibly. If you have such requirements like [...]

Posted in Misc, terminator | Hits: 38083 | No Comments »

Bash script that process input from pipeline or file redirection

2 votos Vota!!

November 15th, 2008 mysurface

I remember I wrote a post regarding how to makes python processing string from the pipeline stream. This time, I find the needs to do it in bash script.
I created a hex string splitter script for my friend who needs to decode the raw data that will be written in hex string such as “5F443D95FEA3D4787AEDC4″. [...]

Posted in Bash, pipeline | Hits: 107273 | 3 Comments »

How to redirect output to a file as well as display it out

4 votos Vota!!

December 6th, 2007 mysurface

To redirect standard output to a file is easy, you just need to use the redirection symbol, for example:
echo “hello world” > test.txt
But what if I want to display it out as well as store into a file?
Answer: tee
echo “hello world” | tee test.txt
Okay it seems very easy, how about append?
Related PostsDisplay & log command [...]

Posted in Text Manipulation, pipeline, python, tee | Hits: 67375 | 12 Comments »

pcregrep, grep based on perl compatible regular expressions

0 votos Vota!!

November 20th, 2007 mysurface

grep supposedly support perl regex by specified -P option, but somehow my grep do not support that, it complains this when I trigger with -P
grep: The -P option is not supported
But when you check the manpage of grep, you will see this
-P, –perl-regexp
[...]

Posted in Regular Expression, Text Manipulation, pcregrep, printf | Hits: 36519 | No Comments »

smart grouping shorten long command line 2

1 votos Vota!!

June 19th, 2007 mysurface

This post is to illustrate additional usage of curly brackets { } for range of numbers, continues from smart grouping shorten long command line.
Let say you have a list of logs where you want to pick a range of logs for analysis, the sample log files shows as bellow

tcp_06062007_1.txt

tcp_06062007_180.txt
tcp_06062007_181.txt
tcp_06062007_182.txt

tcp_06062007_230.txt
In order to archive logs from range [...]

Posted in Symbol, curly brackets, tar | Hits: 30715 | No Comments »

CLI magic: programable bash completion

3 votos Vota!!

May 4th, 2007 mysurface

Ubuntu, a Linux distribution that is getting popular because it has successfully improves it’s user friendliness with simple User interface. You can install any applications with few clicks, configuration under GUI dialogs etc. People usually have the thinking of maybe one day, Ubuntu will become another new operating system like Microsoft Windows.
Never! The concept of [...]

Posted in Bash, apt-cache, apt-get, complete, pipeline, sort, svn | Hits: 48428 | 5 Comments »

Redirect output to multiple processes

0 votos Vota!!

November 8th, 2006 toydi

Since tee can read the standard input, and write to multiple files, we may leverage this feature so that it writes to multiple processes (instead of files).
tee >(process1) >(process2) >(process3) | process4
>( ) (see process substitution) pretends itself as a write-only file. Everything you write into it, will be passed to the command (as standard [...]

Posted in Common, grep, process substitution, tee | Hits: 46996 | 28 Comments »

Compare two directory listings

2 votos Vota!!

November 8th, 2006 toydi

Given two directories: ~/dir-new/ and ~/dir/,
$ ls ~/dir-new/
file-01.txt
file-02.txt
file-new.txt
$ ls ~/dir/
file-01.txt
file-02.txt
file-old.txt
To compare them:
comm

Posted in Text Manipulation, comm, process substitution | Hits: 41734 | 2 Comments »

Rename multiple files

7 votos Vota!!

November 5th, 2006 toydi

Often over time, we will want to reorganize a group of files by renaming them.
To rename *.txt to *.bak
(e.g. to rename ham.txt to ham.bak)
for f in *.txt; do mv “$f” “${f%.txt}.bak”; done
To remove ‘new-’ from new-*
(e.g. to rename new-ham.txt to ham.txt)
for f in new-*; do mv “$f” “${f#new-}”; done
${variable%pattern} vs ${variable#pattern}
The funny-looking symbol, ${f%.txt} [...]

Posted in Common, Regular Expression, for, mv | Hits: 100690 | 16 Comments »

square brackets in regular expression

1 votos Vota!!

October 17th, 2006 mysurface

Previously we have an example on regular expression, but It doesn’t shows the power of square brackets ( [ ] )
Let say you want to search for string fprintf, vprintf and sprintf using grep, usually what you do is
egrep “fprintf|vprintf|sprintf” *.c
You may be ask why don’t just uses the word “printf”? If uses the word [...]

Posted in Regular Expression, Text Manipulation, egrep | Hits: 20625 | 2 Comments »