How to measure the time needed to execute a command
Answer:
Use the time command, e.g.
# time perl -e 'sleep 5'
real 0m5.026s
user 0m0.010s
sys 0m0.020s
The above perl command takes around 5 seconds to execute.
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to measure the time needed to execute a command
Answer:
Use the time command, e.g.
# time perl -e 'sleep 5'
real 0m5.026s
user 0m0.010s
sys 0m0.020s
The above perl command takes around 5 seconds to execute.
Reduce the chance of using swap if you have enough memory
Answer:
If you have enough memory but the Linux is still using swap at sometimes, you can adjust the swappiness parameter
1. See the current setting
# cat /proc/sys/vm/swappiness
60
The range is from 0 to 100 (lower value means you system will try to avoid swap as much as possible)
2. To set a lower value at runtime
# echo "30" > /proc/sys/vm/swappiness
3. To set it permanently
# /sbin/sysctl -w vm.swappiness=30
Reboot after the changes.
How to convert spaces into tabs?
Answer:
You can use the unexpand command
# unexpand test.txtAnother example:# echo -e " A" | unexpand | sed 's/\t/F/g' FA
How to convert tab into spaces?
Answer:
You can use the expand command
# expand test.txt
Another example:
# echo -e "\tA" | expand | sed 's/ /F/g'
FFFFFFFFA
How to find the differences between two files (visually)
Answer:
Use the vimdiff command
E.g.
# vimdiff foo.txt bar.txt
You can enter vim and the differences between two files will be shown visually.