UNIX tips: Learn 10 good UNIX usage habits
2010-04-01 15:31
309 查看
1.Make directory trees in a single swipe
Listing 1 illustrates one of the most common bad UNIX habits around: defining directory trees one at a time.
Listing 1. Example of bad habit #1: Defining directory trees individually
It is so much quicker to use the
Listing 2. Example of good habit #1: Defining directory trees with one command
You can use this option to make entire complex directory trees, which are great to use inside scripts; not just simple hierarchies. For example:
Listing 3. Another example of good habit #1: Defining complex directory trees with one command
In the past, the only excuse to define directories individually was that your
For the few systems that still lack the capability, use the
2.Change the path; do not move the archive
3.Combine your commands with control operators
4.Quote variables with caution
5.Use escape sequences to manage long input
6.Group your commands together in a list
7.Use xargs outside of find
8.Know when grep should do the counting -- and when it should step aside
9.Match certain fields in output, not just lines
10.Stop piping cats
more specifically information please link there:http://www.ibm.com/developerworks/aix/library/au-badunixhabits.html#six
Conclusion: Embrace good habits
It is good to examine your command-line habits for any bad usage patterns. Bad habits slow you down and often lead to unexpected errors. This article presents 10 new habits that can help you break away from many of the most common usage errors. Picking up these good habits is a positive step toward sharpening your UNIX command-line skills.
Listing 1 illustrates one of the most common bad UNIX habits around: defining directory trees one at a time.
Listing 1. Example of bad habit #1: Defining directory trees individually
~ $ mkdir tmp ~ $ cd tmp ~/tmp $ mkdir a ~/tmp $ cd a ~/tmp/a $ mkdir b ~/tmp/a $ cd b ~/tmp/a/b/ $ mkdir c ~/tmp/a/b/ $ cd c ~/tmp/a/b/c $ |
-poption to
mkdirand make all parent directories along with theirchildren in a single command. But even administrators who know about this option are still caught stepping through the subdirectories as they make them on thecommand line. It is worth your time to conscientiously pick up the good habit:
Listing 2. Example of good habit #1: Defining directory trees with one command
~ $ mkdir -p tmp/a/b/c |
Listing 3. Another example of good habit #1: Defining complex directory trees with one command
~ $ mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a} |
mkdirimplementation did not support this option, but this is no longer true on most systems. IBM AIX®
mkdir, GNU
mkdir, and others that conform to the Single UNIX Specification now have this option.
For the few systems that still lack the capability, use the
mkdirhierscript (see Resources), which is a wrapper for
mkdirthat does the same function:
~ $ mkdirhier project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a} |
3.Combine your commands with control operators
4.Quote variables with caution
5.Use escape sequences to manage long input
6.Group your commands together in a list
7.Use xargs outside of find
8.Know when grep should do the counting -- and when it should step aside
9.Match certain fields in output, not just lines
10.Stop piping cats
more specifically information please link there:http://www.ibm.com/developerworks/aix/library/au-badunixhabits.html#six
Conclusion: Embrace good habits
It is good to examine your command-line habits for any bad usage patterns. Bad habits slow you down and often lead to unexpected errors. This article presents 10 new habits that can help you break away from many of the most common usage errors. Picking up these good habits is a positive step toward sharpening your UNIX command-line skills.
相关文章推荐
- Learn 10 good UNIX usage habits --- linux命令(1)
- 10 examples to help you understand top command usage in Unix/Linux
- Unix Less Command: 10 Tips for Effective Navigation
- UNIX 高手的 10 个习惯 http://www.ibm.com/developerworks/cn/aix/library/au-badunixhabits.html
- Learn UNIX in 10 minutes
- Learn UNIX in 10 minutes
- 10 Tips to Improve an ASP.NET Applications Performance
- 通向 UNIX 天堂的 10 个阶梯(ZZ)
- TensorFlow学习笔记10----Logging and Monitoring Basics with tf.contrib.learn
- How Good C# Habits can Encourage Bad JavaScript Habits
- good ruby learn site
- 日志组件系列:(1)Top 10 Tips on Logging in Java
- UNIX 高手的 10 个习惯
- UNIX 高手的 10 个习惯 ZT
- 使用 UNIX 的 10 个良好习惯
- UNIX 高手的 10 个习惯
- STL vector usage tips and problems
- [ORIGINAL CREATION] usful tips on Unix-like system
- Excel SUMPRODUCT formula - Syntax, Usage, Examples and Tutorial | Chandoo.org - Learn Microsoft Excel Online
- Top 10 Java Debugging Tips with Eclipse(Eclipse调试Java的10个技巧)