One of scripts. Tickets will go on making scripts, some introductory and more advanced. Today we will see how to make our scripts can set their variables from external files.
This is especially useful when we update our scripts on different machines and do not want to alter the configuration of each.
copy.sh
# / bin / bash
ruta_origen = / home / juanjo
destination_path = / mnt
function copy {$ cp-vr} ruta_origen $ destination_path With what if we change the script to your computer, maybe / home / junajo not exist. Let's do it right. Create a properties file, for example
copy.sh.properties
And in place: # File
copy.sh Properties property = value
- # source = / home / juanjo
- destination = / mnt
Now in the file add the function copy.sh property: # / bin / bash function
Property {
if test-r $ 0.properties Then - cat $ 0.properties take care!
0 comments:
Post a Comment