Output First bash-3.2$ ./ksh_case_chart.sh Enter your Number 9 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 9 * 6 = 54 9 * 7 = 63 9 * 8 = 72 9 * 9 = 81 9 * …
Category: FromSitesTree.com
Jul 12
Log currently running shell processes into a file in every 30 seconds. #Linux/Unix: Shell Programming – 001
#!/bin/sh #find all currently running shells and create in full listing form for them . Log the data into a file in every 30 secs # -e means currentl running # -f means full format output # sleep takes parameters in seconds ps -ef | grep shell >> process.log sleep 30 ps -ef | grep …
Jul 12
If then else in shell programming. Count the number of files in current directory, and check … #Linux/Unix: Shell Programming – 001
#!/bin/sh #count the number of files in current directory, and check if the number is equal to or greater than or less than 26 #NOF represents number of files NOF=`ls -l | wc -l` if [ $NOF -eq 26 ] then echo “No of files and directories is equal to 26” fi if [ $NOF …
Jul 11
Take Two values from the user and do arithmetic operations #Linux/Unix: Shell Programming – 001
#!/usr/bin/bash clear echo “Enter First Number” read x echo “Enter Second Number” read y #does not work for /bin/sh (( z = $x + $y )) (( a = $x – $y )) (( b = $x * $y )) (( c = $x / $y )) #clear echo “Addition of 2 numbers is =” …
Jul 11
Example use of case in KSH. Show Today’s Day Name #Linux/Unix: Shell Programming – 001
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” ;; Fri) echo “Friday” ;; Sat) …
Jul 11
Use of For Loops and Functions in Shell Programming #Linux/Unix: Shell Programming – 001
bash-3.2$ cat multiplication.sh #!/bin/bash # Example use of function/method declaration in Shell Programming # Example use of for loop #a function that will multiply 1 to 10 with 5 multiplication() { x=5 for i in {1..10} do echo $i echo “the multiplication result is:” $(($i*$x)) done } echo “Print 1 to 10; also multiply each …
Jul 11
Example use of case #Linux/Unix: Shell Programming – 001
Example Output: 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 * 10 = 100 ———————————- #!/bin/bash multi() …
Jul 11
Repair laptop battery at home|| how to open laptop battery and rebuild after repairing #Misc
Watch this for concepts. However, do not do as it is. Take some safety measures and precautions as well. Understanding the theory behind circuits will help. [youtube https://www.youtube.com/watch?v=Da4ilNuUCsg&w=853&h=480] From: http://sitestree.com/?p=12304 Categories:MiscTags: Post Data:2018-09-14 22:15:20 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) …
Jul 11
A Basic Shell Program #Linux/Unix: Shell Programming – 001
#!/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 “and the current time is: …
Jul 11
Examples of using variables in a Shell Program #Linux/Unix: Shell Programming – 001
#!/bin/sh #assign value to a variable and print to the screen NAME=”Justetc” echo $NAME #Ask the user to enter a Name echo ################################## echo “enter name” #read command is used to take input from the user read X #print the value two times to the screen echo $X echo $X ————————— ????? – Output bash-3.2$ …
