Linux Command Line tips for improving office efficiency

Source: Internet
Author: User

Tips for Linux Command Line to improve office efficiency 1. view how often commands are used: www.2cto.com $ history | awk '{print $2}' | awk 'BEGIN {FS = "| "}{ print $1} '| sort | uniq-c | sort-r 4 ls 2 cd 1 who application: regularly check frequently used commands in the history file, and set history not to record these commands to improve the role of the history file. 2. view the shell type $ echo $0-bash application: use the file name to automatically complete the function based on the corresponding shell type. 3. Use History extension www.2cto.com $ grep pickles this-is-a-long-lunch-menu-file.txt pastrami on rye with pickles and onions $ vi! $ Application: you use an exclamation point (!) And then use the dollar sign ($) to return the last field of the previous command. If you repeatedly use long file names, this is a very good tool. 4. Reuse the previous parameter $ mv kxp12.c file_system_access.c $ ln-s! $!: 1 Application :! $ Command returns the previous file name parameter used by a command. But what if a command uses multiple file names and you only want to reuse one of them ?!: 1 operator returns the first file name used by a command. 5. Use pushd and popd to manage the directory navigation $ pushd/etc $ pushd/var/etc $ pushd/usr/local/bin/var/ the etc $ dirs/usr/local/bin/var/etc $ popd/etc $ popdpushd and popd commands also support parameter processing of directory stacks. Use the + n or-n parameter, where n is a number, you can move the stack to the left or right: $ dirs/usr/local/bin/var/etc $ pushd + 1/var/etc/usr/local/bin application: when you want to navigate to multiple directories, but want to quickly return to a location. The pushd and popd commands create a virtual directory stack. The pushd command is used to change your current directory and store it in the stack, the popd command is used to remove the directory from the top of the stack and let you return this location. You can use the dirs command to display the current directory stack without pressing in or popping up a new directory. 6. Do not use the editor to create a temporary file $ cat> my_temp_file.txt This is my temp file text ^ D application: use the cat command without a file name to display only any content typed into the standard input;> redirect to capture the input to the specified file. Therefore, it can be used to quickly create files. 7. recursively create the directory $ mkdir-p tmp/a/B/c $ mkdir-p project/{lib/ext, bin, src, doc/{html, info, pdf}, demo/stat/a} application: You can use the-p option to create a complex directory tree (ideal for use in scripts ), instead of creating subdirectories for each level one by one. 8. Change the path. Do not move the archive $ tar xvf-C tmp/a/B/c newarc.tar.gz application: Set. the tar archive file is moved to a directory because it happens to be extracted from it. tar file directory. In fact, you do not need to do this. You can decompress any. tar archive file to any directory-this is the purpose of the-C option. When extracting an archive file, use the-C option to specify the directory in which the file is to be decompressed. 9. Use $ cd tmp/a/B/c | mkdir-p tmp/a/B/c & tar xvf-C tmp// b/c ~ /Archive.tar application: to quickly complete continuous commands. 10. If possible, do not switch directories frequently.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.