You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 10
Next »
About
Various testing on conditional events or variables (exit test, variable defaults).
Last Command Return Value
if [ $? -eq 0 ]; then
echo "Success"
else
echo "Failure"
if [ $? -ne 0 ]; then
echo "Failure"
else
echo "Success"
Conditionally Set Variables
This one is obscure....<TODO> explain!
Copy Selected Files
cp --parents `find -name .pydevproject` /target_directory/
Install Packages
install_package ()
{
PACKAGE_NAME=$1
dpkg -s ${PACKAGE_NAME} > /dev/null
if [ $? -ne 0 ]; then
sudo apt-get -q -y install ${PACKAGE_NAME} > /dev/null
else
pretty_print " $(padded_message ${PACKAGE_NAME} "found")"
return 0
fi
if [ $? -ne 0 ]; then
pretty_error " $(padded_message ${PACKAGE_NAME} "failed")"
return 1
fi
pretty_warning " $(padded_message ${PACKAGE_NAME} "installed")"
return 0
}
# usage
install_package ansible