Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2017oct13 Language: bash Keywords: success, die Q. How can I check that a cd in a bash script worked? A.if cd /tmp; then echo Worked else echo Failed fiIf you want the script to end when the cd failsif cd /tmp; then : # This means do nothing on success else echo "Could not change to /tmp" exit 1 fi # Remainder of script
Add a commentSign in to add a comment