Squeeze multiple blank lines to one

March 10th, 2007 toydi

Documents like RFCs may contain many blank-line blocks. To save the trees, i always squeeze multiple blank lines down to single blank line, before printing. Once I did this manually (yes, it’s like hell), but now I use cat -s: cat -s rfc2324.txt | tr -d ‘\\f’ | lpr I use tr -d to remove […]

Posted in cat, lpr, Text Manipulation, tr | Hits: 72707 | No Comments »

cut and paste source code to console

January 2nd, 2007 mysurface

If your vim have auto indent enabled, you may facing this problem. Vim are too smart to help you indent copied source code, and the comment line will kill your pasting very much. I usually do copy and paste source code from ebook or web page to a file so that I can compile and […]

Posted in cat, Text Manipulation | Hits: 82915 | 16 Comments »

turn off laptop LCD monitor

November 12th, 2006 mysurface

In order to save power, I often turn off my LCD monitor when I away from keyboard for long. Bare in mind, blank screen is not consider turn off the monitor, because it still uses backlight. To do that, first you need to make sure you have ACPI enabled in your kernel. cat /proc/acpi/info If […]

Posted in cat, Misc, X11, xset | Hits: 111014 | 38 Comments »

beware of non-ascii characters

October 13th, 2006 mysurface

When I copy source code from an ebook in pdf format and paste into vim, and I try to compile it fails. The reason it fails is because it contains non-ascii character, for my case it uses UTF-8 encorded characters. You can check out the non-ascii or hidden characters by doing this: cat -v mycode.c […]

Posted in cat, Misc, sed, Text Manipulation | Hits: 71501 | 5 Comments »

Enable a user to gain write permission when mounting

October 10th, 2006 mysurface

We need to perform mounting with root privilege, but after a simple mounting, we need to be root in order to write to the mounting point. This is the default for a simple mounting, check out more mounting examples here. But we can grant the mount point ownership to other user besides root. We can […]

Posted in Admin, cat, mount, pipeline | Hits: 79767 | 2 Comments »

xargs use stardard output as parameter for another command

October 2nd, 2006 mysurface

xargs is a command line of findutils package. It is not so common for new user, but it is a very useful tools, let me pick an example to show the usage. Bare in mind, xargs is a kind of combo command use together with other command through pipeline. I have a list of links […]

Posted in cat, pipeline, Text Manipulation, wget, xargs | Hits: 80236 | 10 Comments »

generate and print a sequence of number

September 28th, 2006 mysurface

To generate a sequence of number we can use seq seq 1 10 With this it prints 1 to 10 line by line, because by default separator is new line, anyway you can check, do this seq -s” ” 1 10 Doing this it change new line to a single blank space. But that is […]

Posted in backquote, cat, Misc, pipeline, seq, Text Manipulation, wc | Hits: 98404 | 1 Comment »


September 17th, 2006 mysurface

Just to highlight 2 examples of cat here, simple cat from one file to another, cat file1 > file2 all content of file2 will be overwrite and replace with content of file1. cat file1 >> file2 all content of file1 will be paste bellow the content of file2. Related Postscommand line tutorial for beginnersLinux by […]

Posted in cat, Text Manipulation | Hits: 23926 | 1 Comment »

word count

September 17th, 2006 mysurface

Word count is a very common tools that used to calculate number of lines, words and characters. For example if I can do this echo “hello world.” | wc 1 2 13 The result indicate that there are 1 line, 2 words and 13 characters. You can output result separately, -c indicates characters, -w indicate […]

Posted in cat, Common, echo, wc | Hits: 58288 | 2 Comments »

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: 55533 | 4 Comments »