Monday, January 31, 2011

How to create printable version of a man page..?

Most of us are always feel boring to read man pages in terminal window. what if we have a printable version of a particular command's manpage.? Nice isn't it.. so, how we can create a printable version of a manpage...

Step 1: Issue the following command in terminal
$man -t [the_command_you_wish] > destination_file_path.ps

Ex:$man -t mkdir > ~/Desktop/mkdirs_manpage_printableversion.ps

Now you got a file named " mkdirs_manpage_printableversion.ps " in your Desktop :). you can now print and use it..

Note: .ps is the default file type used to print.

Tuesday, January 18, 2011

how to find the pattern within files?

Using grep we achieve this..
Say we have to find out the word "gdk" from all the '.c' files in a directory.. the command would be

$grep -i "pattern" files

ex: $grep -i "gtk" *.c          <===== Will search all .c files in the current directory.
ex: $grep -i "gtk" file1, file.23, file <== Will search only in the specified files.

Find and remove duplicate photos in Linux distros..

While searching I got to know about two softwares for finding the duplicate images in various folders...
1. GQview
2. Digikam (KDE desktop)

Tuesday, January 11, 2011

how to get the information/details about the installed packages in debian linux?

$dpkg -s "package-name"

-s <- is the option for find out the status of the given gives information like

1. The package is installed or not, removed
2. size of the installed package
3. Architecture support
4. Dependency
5 Version and so..

How to fetch n number of lines before or after a pattern match..

Lets assume there is a file which has 1000 lines. Now i want to see 20 lines from the a pattern (say pattern is 'top secret'). How come..?

Step 1: open the file in command prompt using 'cat' command with -n option(this option shows the content of the file with the line numbers).

Ex: $cat -n ./secrets.txt

step 2: piping the output of the 'step 1' to grep command with -i option(this ignores the case of given pattern i.e case insensitive) and pattern.

Ex: $cat -n ./secrets.txt | grep -i 'top secret'

step 3: now your output gives a line number(say 654) with the give pattern match, so, now using the head & tail commands with the line numbers we get the required output.

Ex: $head -654 | tail -10

Thats all.. :)