Remember the path of last login
create ~/.bash_logout
with the following contents:
1 2 | t=`readlink -f \`pwd\`` ln -sfn $t ~/lastdir |
Continue reading ‘Remember the path of last login’ »
Molecular modeling in Materials Sciences Web development Programming IT
Posts tagged ‘bash’
create ~/.bash_logout
with the following contents:
1 2 | t=`readlink -f \`pwd\`` ln -sfn $t ~/lastdir |
Continue reading ‘Remember the path of last login’ »
History Expansion
History expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the arguments to a previous command into the current input line, or fix errors in previous commands quickly.
Continue reading ‘History expansion in depth’ »
There is a ‘-C’ option allow you to do this. However, it can fail in some situation. There are also some posts online that report this option does not work. If you have that problem, maybe you could try the solution here.
Continue reading ‘Uncompress tar to specific directory + Other tar/untar tricks’ »
Bash下可以使用”cd -”来实现在当前目录和上一次访问的路径间切换。 如果我们需要回退多级目录怎么实现呢?
Both Linux Bash and Windows DOS support random number generation. The random number is ‘stored’ in a system environment variable named “RANDOM” (I believe this variable links to a script to generate the actual random numbers on both systems), use it in the same way as you use other ENV variables. E.g.
Windows: there is ‘tree.com‘ command showing the directory structure.
http://chxkyy.javaeye.com/blog/213864
Continue reading ‘Print directory tree on Windows and Linux using tree, sed, awk or Python’ »
Useful commands:
Sometimes after mounting some nfs devices, you cannot easily un-mount them. You get some error: “device is busy”. I often get this error when I want to un-mount some shared folders like ‘/home’ and ‘/usr’.The reason is simple: the devices you are un-mouting are busy;) That’s to say some files on the mouted devices are being used by some process.
It’s always nice to get notified about the status of a long job, e.g. copying a huge file via a not-that-fast network. For GUI programs, normally you get a progress bar, but we have no such luxury under bash. But wait, here is a nice bash script can do that. It works pretty well. You will find it useful in many places.
bash下time是一个很有用的命令,它可以为一段脚本或一个程序的执行计时,这通常在粗略比较程序执行效率的时候很方便。但是你会发现,time命令输出的时间文字不能被简单地重定向,例如重定向至一个文本文件,只能显示在屏幕上,这对于非交互计时很不方便。例如: