Category: FromSitesTree.com

Topic 3: Example : Operator #Linux/Unix: Shell Programming – 001

bash-3.2$ cat operator6.sh #!/bin/ksh x=15.38 y=15.72 ((z = x + y)) echo $z   bash-3.2$ ./operator6.sh 30 From: http://sitestree.com/?p=12234 Categories:Linux/Unix: Shell Programming – 001Tags: Post Data:2018-05-08 15:32:42 Shop Online: https://www.ShopForSoul.com/ (Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com In Bengali: http://Bangla.SaLearningSchool.com http://SitesTree.com 8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) Shop Online: https://www.ShopForSoul.com/ Medium: https://medium.com/@SayedAhmedCanada

Topic 3: Example: Current Info : Variables #Linux/Unix: Shell Programming – 001

bash-3.2$ cat currentinfo.ksh #!/bin/ksh # outputs the day, time, & current month. day=$(date +%D) time=$(date +%T) print “Today is $day.” print print “The time is $time.” print print “This month’s calendar:” bash-3.2$ ./currentinfo.ksh Today is 04/27/18. The time is 10:25:45. This month’s calendar: From: http://sitestree.com/?p=12227 Categories:Linux/Unix: Shell Programming – 001Tags: Post Data:2018-05-05 14:28:58 Shop Online: …

Continue reading

Topic 1: Basic Date Displaying Shell Script #Linux/Unix: Shell Programming – 001

bash-3.2$ cat echoscript1.sh #!/bin/sh #clear echo “SCRIPT BEGINS” echo “Hello $LOGNAME” echo echo “Todays date is: c” date ‘+%m/%d/%y’ echo “and the current time is: c” date ‘+%H:%M:%S%n’ echo “Now a list of the processes in the current shell” ps echo “SCRIPT FINISHED!!” bash-3.2$ ./echoscript1.sh SCRIPT BEGINS Hello shell Todays date is: 04/27/18 and the …

Continue reading

Korn Shell Example: Show Dates #Linux/Unix: Shell Programming – 001

bash-3.2$ cat echoscript2.ksh #!/bin/ksh #clear print “SCRIPT BEGINS” print “Hello $LOGNAME” print print -n “Todays date is: ” date ‘+%m/%d/%y’ print -n “and the current time is: ” date ‘+%H:%M:%S%n’ print “Now a list of the processes in the current shell” ps print “SCRIPT FINISHED!!” bash-3.2$ ./echoscript2.ksh SCRIPT BEGINS Hello shell Todays date is: 04/27/18 …

Continue reading

Topic 2: Logname, Date Time, Shell Script #Linux/Unix: Shell Programming – 001

bash-3.2$ cat firstscript.sh #!/bin/sh #clear echo “SCRIPT BEGINS” echo “Hello $LOGNAME!” echo echo “Today’s date and time: c” date echo mynum=21 myday=”Monday” echo “The value of mynum is $mynum” echo “The value of myday is $myday” echo echo “SCRIPT FINISHED!!” echo bash-3.2$ ./firstscript.sh SCRIPT BEGINS Hello shell! Today’s date and time: Fri Apr 27 08:51:53 …

Continue reading

Topic 2: Example: Comments in Shell Scripts #Linux/Unix: Shell Programming – 001

bash-3.2$ cat scriptwithcomments.sh #!/bin/sh # This script clears the window, greets the user, # and displays the current date and time. #clear # Clear the window echo “SCRIPT BEGINS” echo “Hello $LOGNAME!” # Greet the user echo echo “Todays date and time: c” date # Display current date and time echo mynum=21 # Set a …

Continue reading

Topic 2: Example: Debug a Script #Linux/Unix: Shell Programming – 001

Example debugging a Script   bash-3.2$ sh -x scriptwithcomments.sh + echo SCRIPT BEGINS SCRIPT BEGINS + echo Hello shell! Hello shell! + echo + echo Todays date and time: c Todays date and time: + date Fri Apr 27 09:16:29 EDT 2018 + echo mynum=21 myday=Monday + echo The value of mynum is 21 The …

Continue reading

While Loop Example in Shell Programming. Display a Chart #Linux/Unix: Shell Programming – 001

Example Output bash-3.2$ ./while-loop-example.sh Enter your Number 10 10 * 1 = 10 10 * 2 = 20 10 * 3 = 30 10 * 4 = 40 10 * 5 = 50 10 * 6 = 60 10 * 7 = 70 10 * 8 = 80 10 * 9 = 90 10 * …

Continue reading

On Thursday and Friday tar all contents of /etc folder into /export/home/shell/test/etc.tar .. do misc logs #Linux/Unix: Shell Programming – 001

#!/bin/ksh # on every thursday and friday tar all contents of /etc folder into /export/home/shell/test/. On thursday only create a log file with the list of files #in the tar file. On thursday untar /export/home/shell/test/etc.tar into vfstab . Then log vfstab exist or not information DAY=`date +%a` DATESTAMP=`date +%m-%d-%Y-%H:%M` if [[ “$DAY” == Mon ]] …

Continue reading

If then else example in Shell Programming #Linux/Unix: Shell Programming – 001

#!/bin/sh #If then else example #if elif else NOF=5 if [ $NOF -eq 27 ] then echo “No of files and directories = 27” elif [ $NOF -gt 27 ] then echo “No of files are dir are greator than 27” else echo “No of files and directories are less than 27” fi exit From: …

Continue reading