{"id":65726,"date":"2021-07-12T04:10:05","date_gmt":"2021-07-12T08:10:05","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/topic-2-logname-date-time-shell-script-linux-unix-shell-programming-001\/"},"modified":"2021-07-12T04:10:05","modified_gmt":"2021-07-12T08:10:05","slug":"topic-2-logname-date-time-shell-script-linux-unix-shell-programming-001","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=65726","title":{"rendered":"Topic 2: Logname, Date Time, Shell Script #Linux\/Unix: Shell Programming &#8211; 001"},"content":{"rendered":"<blockquote><p>bash-3.2$ cat firstscript.sh<br \/>\n#!\/bin\/sh<br \/>\n#clear<br \/>\necho &#8220;SCRIPT BEGINS&#8221;<br \/>\necho &#8220;Hello $LOGNAME!&#8221;<br \/>\necho<br \/>\necho &#8220;Today&#8217;s date and time: c&#8221;<br \/>\ndate<br \/>\necho<br \/>\nmynum=21<br \/>\nmyday=&#8221;Monday&#8221;<br \/>\necho &#8220;The value of mynum is $mynum&#8221;<br \/>\necho &#8220;The value of myday is $myday&#8221;<br \/>\necho<br \/>\necho &#8220;SCRIPT FINISHED!!&#8221;<br \/>\necho<br \/>\nbash-3.2$ .\/firstscript.sh<br \/>\nSCRIPT BEGINS<br \/>\nHello shell!<\/p>\n<p>Today&#8217;s date and time: Fri Apr 27 08:51:53 EDT 2018<\/p>\n<p>The value of mynum is 21<br \/>\nThe value of myday is Monday<\/p>\n<p>SCRIPT FINISHED!!<\/p><\/blockquote>\n<p> From: http:\/\/sitestree.com\/?p=12213<br \/> Categories:Linux\/Unix: Shell Programming &#8211; 001<br \/>Tags:<br \/> Post Data:2018-04-29 23:55:03<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>bash-3.2$ cat firstscript.sh #!\/bin\/sh #clear echo &#8220;SCRIPT BEGINS&#8221; echo &#8220;Hello $LOGNAME!&#8221; echo echo &#8220;Today&#8217;s date and time: c&#8221; date echo mynum=21 myday=&#8221;Monday&#8221; echo &#8220;The value of mynum is $mynum&#8221; echo &#8220;The value of myday is $myday&#8221; echo echo &#8220;SCRIPT FINISHED!!&#8221; echo bash-3.2$ .\/firstscript.sh SCRIPT BEGINS Hello shell! Today&#8217;s date and time: Fri Apr 27 08:51:53 &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=65726\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-65726","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":65728,"url":"http:\/\/bangla.sitestree.com\/?p=65728","url_meta":{"origin":65726,"position":0},"title":"Topic 2: Example: Comments in Shell Scripts #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 12, 2021","format":false,"excerpt":"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\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65730,"url":"http:\/\/bangla.sitestree.com\/?p=65730","url_meta":{"origin":65726,"position":1},"title":"Topic 2: Example: Debug a Script #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 12, 2021","format":false,"excerpt":"Example debugging a Script \u00a0 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\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65722,"url":"http:\/\/bangla.sitestree.com\/?p=65722","url_meta":{"origin":65726,"position":2},"title":"Topic 1: Basic Date Displaying Shell Script #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 12, 2021","format":false,"excerpt":"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\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65685,"url":"http:\/\/bangla.sitestree.com\/?p=65685","url_meta":{"origin":65726,"position":3},"title":"A Basic Shell Program #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"#!\/bin\/sh #if enabled - will spit out the script to the screen #set -v #clear the screen clear echo \"SCRIPT BEGINS\" #shows current login name echo \"Hello $LOGNAME\" #shows current date in the same line echo \"Todays date is: c\" date +%m\/%d\/%y #shows current time in the same line echo\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65693,"url":"http:\/\/bangla.sitestree.com\/?p=65693","url_meta":{"origin":65726,"position":4},"title":"Example use of case in KSH. Show Today&#8217;s Day Name #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"bash-3.2$ cat ksh_case_example_1.sh #!\/bin\/ksh #show today's day name DAY=`date +%a` #show value of $DAY echo $DAY #based on the value of the DAY variable show the day name in full format case \"$DAY\" in Mon) echo \"Monday\" ;; Tue) echo \"Tuesday\" ;; Wed) echo \"Wednesday\" ;; Thu) echo \"Thursday\" ;;\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65724,"url":"http:\/\/bangla.sitestree.com\/?p=65724","url_meta":{"origin":65726,"position":5},"title":"Korn Shell Example: Show Dates #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 12, 2021","format":false,"excerpt":"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\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65726"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65726\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65726"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}