Shell Script Help
I am stuck at some point with shell scripting.
I want to write a shell script which can read commands in a text file and execute the commands.
Suppose I have
cp -r [etc]
mkdir -p [etc]
these commands are in a text file.
I have written a script which can read from the file and display the lines but I want to execute the cp -r [etc] and mkdir -p [etc] with this script.
So can anyone of you help me with this.
Hello and welcome,
I am not sure I understand what you are asking.
If you mean you want to execute the commands that are in a text file, make that text file executable and then run it, e.g.:
you can also simply source a script in Bash, e.g.:
these commands will be run in your current shell, though, not a separate shell, as in the previous case.
You can also post the content of your text/scripts, so that we may fully understand what you are after.
No.. That's not what I was looking for.
Anyways one of my friend helped me and thank you very much for your reply.
He suggested I use eval $variable in the script so that the commands I get from the text file can be executed.
Great, glad you got it sorted.
You can mark the thread as Solved if you're happy (see the Thread Tools at the top of the page).