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.

Jan 262010
 

How to sort IP addresses in Linux

Answer:

When you have a file ip.txt contains a list of IP addresses, e.g.

127.0.0.2
127.0.0.1
10.10.10.1

To sort it, you can use the following command

# sort -t. -k1,1n -k2,2n -k3,3n -k4,4n ip.txt

10.10.10.1
127.0.0.1
127.0.0.2
Jan 252010
 

How to avoid saving current shell session history

Answer:

It might be happened to your before that you don't want to save the current shell session history, but you don't want to clear all the history by executing "history -c", you can use the following method.

# unset HISTFILE

Logout and type history and you will see last session history was not saved.

Jan 252010
 

Create a temp file in Linux

Answer:

To create a temp file in Linux, you can use the mktemp command

E.g.

# mktemp foo.XXXXXXXXXXX

foo.aAIYdsa5027

mktemp will replace XXXXX... by random characters and create that temp file for you.