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.

Jun 152011
 

Auto create complete directory structure when copying files in Linux

Answer:

Assume you are copying file using the command below:

# cp foo/bar/test.txt /tmp/

The result is test.txt will be placed inside the folder /tmp/.

In order to let the cp command auto create the foo/bar/ directory structure under /tmp, you can try the command:

# cp --parent foo/bar/test.txt /tmp/

May 262011
 

Revert the effect of an earlier changeset in Mercurial

Answer:

In Mercurial, if you want to revert the effect of an earlier changeset, even the changes have been pushed to remote, it is still possible with the hg backout command.

1. Find the revision you want to backout using hg log
# hg log

2. Assume you want to backout to the revision 99, then you can
# hg backout -r 99

May 242011
 

Printing the exclamation mark using echo

Answer:

You might observed a problem when you try to print the exclamation mark (!) using the echo command

E.g.

# echo "test!"
-bash: !": event not found

To solve it, you can use single quote instead

# echo 'test!'
test!