linux - Assign command output to variable in Bash? -


i know seems trivial. have no idea going wrong. have shell script download package based on input argument , extract package name. how it:

wget $1 echo $1 | awk -f/ '{print $nf}' 

i run bash scrip.sh http://apache.claz.org/phoenix/apache-phoenix-4.10.0-hbase-1.2/bin/apache-phoenix-4.10.0-hbase-1.2-bin.tar.gz

i download package , second line splits input variable along / delimiter apache-phoenix-4.10.0-hbase-1.2-bin.tar.gz. want assign result of second line variable. change script dir=$($1 | awk -f/ '{print $nf}') , add echo $dir script see result. keep running error : line 2: http://apache.claz.org/phoenix/apache-phoenix-4.10.0-hbase-1.2/bin/apache-phoenix-4.10.0-hbase-1.2-bin.tar.gz: no such file or directory

i tried wrapping command `` problem persists. not cd-ing directory have no idea why error keeps showing up.


Comments