页面

显示标签为“bash”的博文。显示所有博文
显示标签为“bash”的博文。显示所有博文

2011-02-19

修改文件日期戳

$ touch -t yyyyMMddHHmmSS foobar.txt

2011-02-09

用gnu screen管理会话

这里有篇文章很详细地介绍了如何使用gnu screen:
http://www.ibm.com/developerworks/cn/linux/l-cn-screen/

2010-11-28

temporarily changing language for bash output

One may want to temporarily change language for bash'es output some time (like me, reporting bug), and the output language is different from the main locale configuration. Then just prefix `LC_ALL=C' to a command to change to English, e.g.:
# LC_ALL=C aptitude full-upgrade

2009-05-18

bash cheat sheet

  1. Bash keyboard shortcut:
    1. Ctrl + A: Go to the beginning of the line you are currently typing on
    2. Ctrl + E: Go to the end of the line you are currently typing on
    3. Ctrl + L: Clears the Screen, similar to the clear command
    4. Ctrl + U: Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
    5. Ctrl + H: Same as backspace
    6. Ctrl + R: Let's you search through previously used commands
    7. Ctrl + C: Kill whatever you are running
    8. Ctrl + D: Exit the current shell
    9. Ctrl + Z: Puts whatever you are running into a suspended background process. fg restores it.
    10. Ctrl + W: Delete the word before the cursor
    11. Ctrl + K: Clear the line after the cursor
    12. Ctrl + T: Swap the last two characters before the cursor
    13. Esc + T: Swap the last two words before the cursor
    14. Alt + F: Move cursor forward one word on the current line
    15. Alt + B: Move cursor backward one word on the current line
    16. Tab: Auto-complete files and folder names
  2. A good reference on how to manage jobs: Job Control

  3. online manual
  4. assign output of a command to a parameter (i.e. variable)
    var=$(command)
  5. assign result of a command to a parameter (i.e. variable)
    var=$((command))
  6. square bracket ('[' and ']') means test expression (see manual, section 'Bourne Shell Builtins'). There is a table of Bash Condition Expressions here.

2008-07-04

Bash重定向释疑

“<&”、“>&”释疑:“&”在后;只用于做操作符为文件描述符(file descriptor)时,意义同不加“&”。
一个比较好的参考:Bash的输入输出重定向。