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.

Count the number of lines contain a specific string using grep

Answer:

Usually when you want to count the number of lines contain a specific string, it is easy with the grep command,

e.g.

# cat input.txt | grep foo | wc -l

But actually a more direct approach would be:

# cat input.txt | grep -c foo

Move cursor to the start of line in VIM

Answer:

In our previous article, we learned how to move cursor to the end of line in VIM, so how about move to the start of the line?

The answer is simple:

0

Move cursor to the end of the line in your shell

Answer:

In our previous article we learned how to move cursor to the start of the line, so how about the end of the line?

Answer:

Ctrl + e

Move cursor to the start of the line in your shell

Answer:

Assume you have typed a long command, how to move to the start of the line?

The answer is..

Ctrl + a

How to compress a directory to a zip file

Answer:

To compress a directory and all the files under this directory to a zip file, you can use

# zip -r output.zip directory