Linux:bash之命令替换

使用方法:使用bash执行一个命令时,将另一个bash命令的执行结果作为命令元素。

例子:

    1:自定义打印当前所在路径

        [root@m01 etc]# cd /etc/sysconfig/
        [root@m01 sysconfig]# echo "the current dirctory is $(pwd)"
        the current dirctory is /etc/sysconfig

    2:创建一个以当前时间作为文件名的文件

        [root@m01 ~]# touch ./$(date +%F-%H-%M-%S).txt
        [root@m01 ~]# ls
        2018-06-27-11-03-34.txt  anaconda-ks.cfg  chenxu-2018-06-27-10-53-44.txt  chenxu-.txt  id_rsaff.sh          nginx-1.12.0.tar.gz  sort.txt

    3:文件名通配

    man 7 glob查看规则!

    

猜你喜欢

转载自blog.csdn.net/administrator4/article/details/80825964
今日推荐