Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Sep 232010
 

Open UTF8 file with Vim

Answer:

If you opened an UTF-8 file, you need to let vim know by using the command below, after entering the command mode by pressing Esc + :

: set encoding=utf8

Sep 192010
 

Code formatting and indentation in VIM

Answer:

Vim support code formatting and auto indentation - if you tell Vim to know the filetype (either by file extension, or by setting the filetype)

e.g. A simple C program (test.c)


#include 

main()
{
for(int i=0;i<10;i++)
{ 
printf ("Hello World!\n");
}
}

Then type following in Vim command mode (by pressing Esc):

gg=G

Now the code will be formatted to:

#include 

main()
{
    for(int i=0;i<10;i++)
    {
        printf ("Hello World!\n");
    }
}
Feb 072010
 

How to perform checksum on a folder?

Answer:

Previous article told you how perform checksum on a file. How about to perform checksum on a folder?

A simple solution is to install md5deep

# sudo apt-get install md5deep

To perform checksum on a particular folder (input),

#  md5deep -l -r input

26ab0db90d72e28ad0ba1e22ee510510  input/2.txt
6d7fce9fee471194aa8b5b6e47267f03  input/3.txt
b026324c6904b2a9cb4b88d6d61c81d1  input/1.txt

That's so easy.

Reference: http://md5deep.sourceforge.net/

Jan 132010
 

How to split a large file into multiple smaller files in Linux

Answer:

If you have a very large file and want to split into multiple smaller files, split command can do the job for you.

# split -l 10 text.txt

The above command split the file text.txt into a multiple files (xaa, xab, xac...), which contains at most 10 lines per file.