Unit Shell Script

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Unit Shell Script as PDF for free.

More details

  • Words: 303
  • Pages: 2
#! /usr/bin/ksh #####if loop work###### USAGE="$0 userid" if [[ $# -ne 1 ]] then echo "Proper Usage: $USAGE" exit 1 fi if who | grep $1 > /dev/null then echo "$1 is active" else echo "$1 is not active" fi exit ################################################### #! /usr/bin/ksh #####if loop work###### USAGE="$0 username" if [[ $# -ne 1 ]] then echo "Proper usage: $USAGE" exit 2 fi grep $1 /etc/passwd > /dev/null if [[ $? -eq 0 ]] then echo "$1 is a valid user" exit 0 else echo "$1 is not a valid user" exit 1 fi ################################################### #! /bin/ksh #####if loop work###### if [ $# = 0 ] then echo "Please write your name." elif [ $1 = 'Jin' ] then echo "Jin,please contract me now." else echo "Hello,$1. get out!!!" fi ################################################### #! /bin/ksh #####if loop work###### if test 'whoami'=root then echo Yes, you are root else echo No, you are 'whoami' fi ################################################### #! /bin/ksh #####read command work###### echo "Please enter the file name:" read name if [[ -f $name ]] then rm $name else echo "Error: $name is not an ordinary file"

fi ################################################### #! /bin/ksh #####f loop work###### for var in f1 f2 f3 do wc -l $var done ################################################### #! /bin/ksh #####while loop work###### x=1 while [[ $x -lt 9 ]] do echo "It is now $(date)" echo "There are $(ps -e | wc -l) processes running" echo "There are $(who | wc -l) users logged in" x=$(expr $x + 1) sleep 600 done ################################################### #! /bin/ksh #####while loop work###### count=1 while [ -n "$*" ] do echo "This is parameter no $count $1" shift count=`expr $count+1` done ################################################### #! /bin/ksh echo first parameter entered was $1 echo second parameter entered was $2 echo third parameter entered was $3 echo $# echo $* echo $? echo $0 echo $$ ###################################################

Related Documents

Unit Shell Script
May 2020 8
Shell Script
November 2019 15
Unix Shell Script
June 2020 7
Shell Script Appendix
June 2020 10
Shell Script Programming
October 2019 18