【Shell】Expansion 悠悠 2022-02-23 08:26 126阅读 0赞 shell命令在执行之前会将做expasion操作,比如: [jiangjian@localhost ~]$ ls demo.txt Desktop Documents Downloads jenkins-2.164.1-1.1.noarch.rpm Music Pictures Public shell Templates test Videos [jiangjian@localhost ~]$ echo [[:upper:]]* Desktop Documents Downloads Music Pictures Public Templates Videos [jiangjian@localhost ~]$ expansion的种类: * pathname expasion: * tidle expasion * arithmetic expansion * brace expansion * parameter expansion * command substitution 如下是使用示例: [jiangjian@localhost shell]$ ls *.txt # pathname expansion a-hard-link.txt a-soft-link.txt b-1.txt b.txt [jiangjian@localhost shell]$ echo ~ #tidle expansion /home/jiangjian [jiangjian@localhost shell]$ echo $((1+3)) # arithmetic expansion 4 [jiangjian@localhost shell]$ mkdir { 2007..2009}-{ 1..12} # brance expansion [jiangjian@localhost shell]$ ls 2007-1 2007-11 2007-2 2007-4 2007-6 2007-8 2008-1 2008-11 2008-2 2008-4 2008-6 2008-8 2009-1 2009-11 2009-2 2009-4 2009-6 2009-8 a-hard-link.txt b-1.txt 2007-10 2007-12 2007-3 2007-5 2007-7 2007-9 2008-10 2008-12 2008-3 2008-5 2008-7 2008-9 2009-10 2009-12 2009-3 2009-5 2009-7 2009-9 a-soft-link.txt b.txt [jiangjian@localhost shell]$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [jiangjian@localhost shell]$ file $(ls /usr/bin/* | grep bin/zip) 或者 file `ls /usr/bin/* | grep bin/zip` # command substitution /usr/bin/zip: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=7c01940c97abdf45a093c697e63ef214ea14adcf, stripped /usr/bin/zipcloak: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=e0f7de70feffd0124f6350e449b8d6c7513502da, stripped /usr/bin/zipdetails: Perl script, ASCII text executable /usr/bin/zipgrep: POSIX shell script, ASCII text executable /usr/bin/zipinfo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=871b5a9c440eb0a275af4db71cdd79778b1fd790, stripped /usr/bin/zipnote: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=750c11ada0bec740fa2885383e678e7be5206cdd, stripped /usr/bin/zipsplit: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=e259ffcdb17baf5b9599c87ad924eb51b4df53b4, stripped
还没有评论,来说两句吧...