shell - Assign output of mkdir command to variable -


i trying assign output of mkdir command variable. can use directory further.

-bash-4.1$ pwd /user/ravi/myscripts/tmpdata -bash-4.1$ output=$(mkdir tmpbkp.`date +%f`) -bash-4.1$ ls | grep tmp tmpbkp.2017-04-06 -bash-4.1$ echo "$output" 

but directory name not assigning variable. please correct me wrong.

when run mkdir command itself, how output produces:

$ mkdir foo $ 

none!

when use command substitution generate argument mkdir, how output get:

$ mkdir tmpbkp.`date +%f` $ 

none!

when put inside $() still produces no output.

there -v option mkdir (in gnu version @ least) produces output, it's not want.

you want name of directory in variable? put in variable first, call mkdir.

$ thedir=tmpbkp.`date +%f` $ mkdir $thedir $ echo $thedir tmpbkp.2017-04-06 $ 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -