Created
December 11, 2015 08:57
-
-
Save klang/e73107562cf83031dc6e to your computer and use it in GitHub Desktop.
An easy way to specify a destination as a single input parameter and still be able to get the individual data elements back again.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[klang@ergates bin]$ split_destination-test.sh | |
destination user@host.with.full.domain:/full/path/to/install/package.ext | |
server host.with.full.domain | |
servershort host | |
user user | |
fullpath /full/path/to/install/package.ext | |
path /full/path/to/install/ | |
package package.ext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PWD=$(pwd) | |
source $PWD/split_destination.sh user@host.with.full.domain:/full/path/to/install/package.ext | |
echo "destination $destination" | |
echo "server $server" | |
echo "servershort $servershort" | |
echo "user $user" | |
echo "fullpath $fullpath" | |
echo "path $path" | |
echo "package $package" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# An easy way to specify a destination as a single input parameter is: | |
# user@host.with.full.domain:/path/to/install/package.ext | |
# To get the individual data elements back again, this script can be used. | |
destination=$1 | |
server=${destination/#*@/} | |
server=${server/:*/} | |
servershort=${server/\.*/} | |
user=${destination/@*/} | |
fullpath=${destination/*:/} | |
package=${destination/*\//} | |
path=${fullpath/$package/} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment