Viewing 1 to 5 of 5 items
Tag Archives: Variables

sh current_dir

Assuming you’re using bash #!/bin/bash current_dir=$(pwd) script_dir=$(dirname $0) echo $current_dir echo $script_dir This script, when ran, should print the directory that you’re in, and then the directory the script is in, for example, when calling it from / (the script is in /home/mez/), it outputs / /home/mez Remember, when assigning variables from the output of  Full Article…

0

grep inside for-loop

dont use capital letter vars. those are better used by the environment. never try to parse ls output. use globbing instead. if you’re writting bash, then prefer [[ over [. do not cat file to read it. instead read it in a while loop. always quote your variables. they’re also easier found if grouped. treat a list of files, as an array. if you  Full Article…

0

.sh file syntax checking script

This isn’t a question–its a solution! Below is a script that I wrote for my own script file development which does what the title says. Its the closest that you can get to compiling what are otherwise purely interpreted script files. I offer it here simply for the benefit of anyone else writing script files.  Full Article…

0

How do I send email from a Sun System (use mailx)?

#!/bin/sh # # Purpose: Demonstrate how to send an email from UNIX using mailx. ############################################################ # Example 1 – Simple: echo “This is the body.”| mailx -s “mailx Test1” jsmith@abc.com # Example 2 – Using Variables: SUBJECT=”mailx Test2″ EMAIL_ADDRESS=”jsmith@abc.com” BODY=”This is the body of the message.” echo “$BODY” | mailx -s “$SUBJECT” “$EMAIL_ADDRESS” # Example 3  Full Article…

0