I wanted to create a script that executes the ls command with the provided arguments. Why isn't it working?
I tried running it with for example -R, then it echoes (I echoed the same thing for comparison):
ls "-R"
but says that it cannot access "-R": no such file or directory. But when I execute ls "-R" in the terminal, it works.
The script itself:
text='ls'
while [[ $# -gt 0 ]]
do
text+=' "'
text+=$1
text+='"'
shift
done
echo 'ls "-R"'
echo $text
$text