#!/bin/bash# Use echo to turn the string variable into a pseudo arrayecho"${pseudoArray}” | while read line; do echo "${line}”;echo"----";# To show I am processing each line in turndone
#!/bin/bashMY_UID=$(id | grep 'uid=0(root)');# Running as root or using sudoif[ -n ${MY_UID}];thenecho “You must run this tool as your normal user and not using sudo”;exit1;else sudo -k;#Reset sudo timestamp. Doesn’t require a password sudo ls / > /dev/null;#have the user enter their sudo passwordif[$? -gt 0];thenecho -e “You did not enter the correct sudo password…\nExiting!”;exit1;fifiecho “You now have been validated as a user with sudo privileges!”
exit0;
#!/bin/bashsomeCommand 2> /dev/null;# Do the command but don’t show an error to the user if one occursif[$? -ne 0];thenecho “An Error Occurred”;# Do something about itfiOR
someCommand;# Show the error to the user, if any, and then do something about itif[$? -ne 0];thenecho “An Error Occurred”;# Do something about itfi