Reputation: 157
I haven't written any Shell scripts before, but i have to write a simple shell script to do the following;
I will keep all the required files in a single folder and bundle it with this shell script as a tar file; so when the user runs the shell script, it needs to copy the respective files to the respective destinations.
The execution of copy as follows:
copy the plugin.so file to /usrlib/mozilla/plugins/
copy the .so library files to /usr/local/lib/
copy some header files directories(folders) to /usr/local/include/
and finally, need to do ldconfig.
Upvotes: 8
Views: 80226
Reputation: 11890
Basically, you can add in a script any command you are able to type inside the terminal itself. Then, you have two options for executing it:
sh your_script.sh
. You don't even need to give execute permission to it with this solution../your_script.sh
.For the second solution, you have to start the file with what is called a shebang
. So your script will look like:
#!/bin/sh
cp path/to/source path/to/destination
cp path/to/source path/to/destination
cp path/to/source path/to/destination
ldconfig
echo "Done!"
Nothing else. Just write the commands one after the other.
The first line is the so-called shebang
and tells the shell which interpreter to use for the script.
Note: the extension for shell scripts is usually .sh
, but you can actually name your file however you prefer. The extension has no meaning at all.
Good scripting!
Upvotes: 16