The following code is used to create a file in exactly location.However result of running test.sh abc is
touch: missing file operand
#! /bin/sh
#test.sh
location='~/configuration/'$1
echo $location
touch `$location`
Is there anything wrong?Thanks!
By putting
$locationin backticks, you’re trying to execute the value of$locationand use that as the argument totouch(see here, section 3.4.5) Just do:If you run
#!/bin/shwith the-xvalue, you’ll see more clearly whatbashis doing in your shell script. It’s a very useful means to debug scripts.