#!/bin/bash
mainDir="$1"
fileName="$2"
preCommand="$3"
echo ${mainDir}
echo ${fileName}
echo ${preCommand}
I am trying to insert text and arguments from earlier calls into arguments for another script.
./script.sh "dir1" "filename" "text with ealier agrument ${mainDir}"
The echo from my script always returns: "text with ealier agrument"
Is it possible to do this in a script?
${mainDir}to be replaced withdir1in this example.${mainDir}is expanded by the shell before your script is called, and it won't be expanded inside the shell.