linux 命令输出作为另一个命令输入 cd

1、ls |tail  >out1.txt

    eg:

       

ps -ef | grep redis-server | grep -v grep | awk '{print $2}'

  

2、子shell法

       output=$( ls |cat -n )

3、反引用:

      output1=`ls|cat -n`

      echo $output1

      

3.1
# cd `echo $JAVA_HOME`
3.2:a=echo $JAVA_HOME
cd $a

  

4、xargs

      

ps -ef | grep redis-server | grep -v grep | awk '{print $2}'  | xargs ./test

  

纸上得来终觉浅,绝知此事要躬行。
原文地址:https://www.cnblogs.com/cbugs/p/15504404.html