The Linux command line learning Note II

Source: Internet
Author: User
Tags echo d

About Command Extensions (Expansion)


Echo

[[email protected] ~]# echo * #* is expanded to file name 0227_2.sh 02273.sh 0227.sh anaconda-ks.cfg Desktop Documents Downloads err.txt I  Nitial-setup-ks.cfg Music perl5 Pictures public Templates test test.txt Videos vmware-tools-distrib[[email protected] ~]# echo "*" #print * *
[Email protected] ~]# echo d* #显示以D开头的文件或目录Desktop Documents downloads[[email protected] ~]# echo *s #显示以s结尾的文件或目录D Ocuments Downloads Pictures Templates videos[[email protected] ~]# echo [[: upper:]]* #显示以大写字母开头的文件或目录Desktop Documents Downloads Music Pictures Public Templates Videos
[[email protected] ~]# echo ~ #~ extension/root
[[email protected] ~]# echo $ ((3+2)) #算数扩展5 [[email protected] ~]# echo $ (((3+2)) 25[[email protected] ~]#
[[email protected] ~]# echo $ ((3**2)) #** take power 9[[email protected] ~]# echo $ ((3**4)) 81

Curly brace Extension

[Email protected] ~]# echo a{1,2,3}a1 A2 A3
[[email protected] testdir]# mkdir {2014..2015}-{01..05}[[email protected] testdir]# ls2014-01 2014-02 2014-03 2014-04 2014-05 2015-01 2015-02 2015-03 2015-04 2015-05

Variable extension

[Email protected] testdir]# echo $HOSTNAMEcentos 7rzc.jacen

Command substitution

[[email protected] testdir]# echo $ (LS) 2014-01 2014-02 2014-03 2014-04 2014-05 2015-01 2015-02 2015-03 2015-04 2015-05[[em AIL protected] testdir]# echo ' ls ' 2014-01 2014-02 2014-03 2014-04 2014-05 2015-01 2015-02 2015-03 2015-04 2015-05
[[email protected] testdir]# ls-l $ (which file)-rwxr-xr-x. 1 root root 19752 June 9 2014/usr/bin/file

Double quotes

[[email protected] testdir]# echo this is  a      word!     #多个空格被识别为1个this  is a word! [[email protected] testdir]# echo  "this is a       word!  "     #多个空格解决方案this  is a      word! 
[[email protected] testdir]# echo  "$ (ls -l)"      #请与下面的内容对比total  40drwxr-xr-x. 2 root root 4096 Mar  5 03:38  2014-01drwxr-xr-x. 2 root root 4096 mar  5 03:38  2014-02drwxr-xr-x. 2 root root 4096 mar  5 03:38  2014-03drwxr-xr-x. 2 root root 4096 mar  5 03:38  2014-04drwxr-xr-x. 2 root root 4096 mar  5 03:38  2014-05drwxr-xr-x. 2 root root 4096 mar  5 03:38  2015-01drwxr-xr-x. 2 root root 4096 mar  5 03:38  2015-02drwxr-xr-x. 2 root root 4096 mar  5 03:38  2015-03drwxr-xr-x. 2 root root 4096 mar  5 03:38  2015-04drwxr-xr-x. 2 root root 4096 Mar  5 03:38 2015-05[[email protected] testdir]# echo  $ (ls -l)      #换行符被识别为分隔符total  40 drwxr-xr-x. 2 root root  4096 Mar 5 03:38 2014-01 drwxr-xr-x. 2 root root 4096  mar 5 03:38 2014-02 drwxr-xr-x. 2 root root 4096 mar 5  03:38 2014-03 drwxr-xr-x. 2 root root 4096 mar 5 03:38  2014-04 drwxr-xr-x. 2 root root 4096 mar 5 03:38 2014-05  Drwxr-xr-x. 2 root root 4096 mar 5 03:38 2015-01 drwxr-xr-x.  2 root root 4096 Mar 5 03:38 2015-02 drwxr-xr-x. 2  Root root 4096 mar 5 03:38 2015-03 drwxr-xr-x. 2 root root  4096 mar 5 03:38 2015-04 drwxr-xr-x. 2 root root 4096 mar 5 03:38  2015-05

Single quotation marks

[[email protected] testdir]# echo $USERroot [[email protected] testdir]# echo ' $USER ' #单引号内不进行变量扩展 $USER

Transfer character

[[email protected] testdir]# echo \$ \ \ t \n$ \ t n[[email protected] testdir]# echo-e "\$ \ t \ n" $ \ [[Email Pro] Tected] testdir]# [[email protected] testdir]# echo "\$ \" $ ' \ t \ n ' #使用 $ can play the role of-e $ \ [[email protected] testdir]#

\a Bell ("Alert"-Causes the computer to beep)
\b Backspace
\ Newline. On Unix-like Systems, this
Produces a linefeed.
\ r Carriage Return
\ t Tab


The Linux command line learning Note II

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.