Linux Shell Usage Tips

Source: Internet
Author: User

Create multiple catalogs at once

[Email protected] tmp]# mkdir-p/user/{folder1,folder2,folder3} [[email protected] tmp]# Ls/user/folder1 Folde R2 Folder3

Find the largest 10 directories in the root directory and sort them from large to small by using space

[Email protected] ~]# du-a./| Sort-nr | Head-n 132380./132316./source 69916./source/zendguard-5_5_0.tar.gz 18720./source/xunza I.com_mysql-5.0.18.tar.gz 13732./source/php-5.4.11.tar.gz 6144./source/phpmyadmin-3.5.6-all-languages.tar.     GZ 5996./source/httpd-2.4.3.tar.gz 5044./source/libxml2-2.9.0.tar.gz 1984./source/pcre-8.32.zip 1960./source/freetype-2.4.10.tar.gz

Look at the root directory under all "." The file that starts with

[Email protected] ~]# find./-name ". [^.] * "./.bash_logout./.bash_profile./.bashrc./.tcshrc./.cshrc./.cache./.config./.bash_h Istory./.xauth96wqte./.mysql_history./.mysql_history. TMP./.viminfo

Modify the timestamp of a file or directory

[[email protected] ~]# stat person.txt      file: ?. erson.txt?       size: 74             blocks: 8          io  block: 4096   regular file     device: 803h/2051d     Inode: 145535279   Links: 1      access:  (0644/-rw-r--r--)   Uid:  (    0/    root)    Gid:  (    0/    root)       context: unconfined_u:object_r:admin_home_t:s0     access: 2016-04-02  05:05:10.370059171 -0700     Modify: 2016-04-02  05:04:40.854898705 -0700  &nbSp;  change: 2016-04-02 05:04:40.913901033 -0700     birth:  -     [[email protected] ~]# touch -t 201604052135  person.txt  #格式为YYMMDDhhmm      [[email protected] ~]# stat  person.txt       file: ?. erson.txt?       size: 74             blocks: 8          io  block: 4096   regular file     device: 803h/2051d     Inode: 145535279   Links: 1      access:  (0644/-rw-r--r--)   Uid:  (    0/    root)    Gid:  (    0/  &NBsp; root)      Context: unconfined_u:object_r:admin_home_t:s0      Access: 2016-04-05 21:35:00.000000000 -0700      modify: 2016-04-05 21:35:00.000000000 -0700     change:  2016-04-05 06:36:16.304945163 -0700     birth: -

Quick backup of one file: CP Filename{,.bak}

[[email protected] ~]# ls anaconda-ks.cfg person.txt source [[email protected] ~]# CP Person.txt{,.bak} [[EMA Il protected] ~]# ls anaconda-ks.cfg person.txt person.txt.bak source

Process runs to the background

[[email protected] ~]# Ctrl + Z

Process runs to the foreground

[[email protected] ~]# FG

Hexadecimal number of randomly generated 10-character numbers

[email protected] ~]# OpenSSL Rand-hex c3e805e84074211cc698

Unzip the file to a new directory

[[email protected] src]# ls    apr-1.4.6.tar.gz         libmcrypt-2.5.8.tar.gz     apr-util-1.5.1.tar.gz    libpng-1.5.14.tar.gz     autoconf-2.69.tar.gz     libxml2-2.9.0.tar.gz     debug                    pcre-8.32.zip      freetype-2.4.10.tar.gz  php-5.4.11.tar.gz     gd-2.0.35.tar.gz         phpMyAdmin-3.5.6-all-languages.tar.gz      Httpd-2.4.3             xunzai.com_ mysql-5.0.18.tar.gz     httpd-2.4.3.tar.gz       Zendguard-5_5_0.tar.gz     jpegsrc.v8b.tar.gz      zlib-1.2.7.tar.gz     kernels      [[email protected] src]# tar zxvf apr-1.4.6.tar.gz -c  /tmp/tmp/     apr-1.4.6/     apr-1.4.6/shmem/      apr-1.4.6/shmem/win32/     ............      [[email protected] src]# ls /tmp/tmp/     apr-1.4.6

Move all files with "TXT" in the file name into the "/tmp/tmp" directory

[Email protected] ~]# find-iname "*txt*"-exec mv-v {}/tmp/tmp/\; ?. /person.txt?. ?.     Tmp/tmp/person.txt? ?. /person.txt.bak?. ?.     Tmp/tmp/person.txt.bak? [Email protected] ~]# ls/tmp/tmp/apr-1.4.6 person.txt Person.txt.bak

Remove any line starting with "#"

[email protected] ~]# Cat A.txt This is the file #This are another file #This is the final file [email pro tected] ~]# sed ' 2s/^#//' a.txt This is the file that is another file #This is the final file


This article is from the "WE become whatwepractice" blog, please be sure to keep this source http://nearlv.blog.51cto.com/2432295/1771641

Linux Shell Usage Tips

Related Article

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.