search

Loading

Wednesday, June 5, 2013

How to run bash script in debug mode

Running the bash script in debug mode help us understand what is going on in the script before getting the output. This also help us find why our program didn't run if there is any issue.

It is just like step by step processing of the bash program.

We can use the below command to run the bash script in debug mode in run time.

How to format golang code

Golang is a language developed at Google. More information can be found at the wikipedia page.

Go has an easy tool called gofmt  to format the code blocks of go program in easy readable format.

Here is the command to format the golang program using gofmt   and save it to the corresponding file.

Friday, May 31, 2013

Print sum of all numbers in a file in linux using awk

This is to print the sum of all numbers in a file using awk.

If the file which we want to process is sum.txt, and it's content is :

cat sum.txt
1
3
2
4
5


 To find the sum of all these numbers we can use below command:

How to join all lines in a file using comma as delimiter?

Sometimes we want to combine the lines in a file as single line. How to achieve this in linux using command line?

We can use the command 'paste' for this purpose.

From its man page,

paste - merge lines of files


Saturday, March 2, 2013

How to run checkdisk on windows in external hard disk

Let's assume that the external hard disk is drive H, then open windows command line 'cmd' as Administrator and run the following command

chkdsk h: /f

Here /f is used to run it in forced mode.