- Tags:
- Show more
- Pages:
- 2
- Words:
- 550
To: From: Date: Linux Script 1 #!/bin/sh#Display the date getDate(){ date return } info=$(uname -a) date=$(getDate) user=$(id) echo The Current Date is $date echo Username and Id: $user echo System Information: $info echo Our Current Working Directory is $PWD Output results are as shown below centertop Linux Script 2 #!/bin/bash getDate(){ date return } theDate=$(getDate) info=$(uname -a) user=$(id) cd /tmp #search for 'Mary' in /etc/passwd name='Mary' search=$(grep $name /etc/passwd) if then echo $name is a user in the system else echo $name is not a user in the system fi #display date echo The Date is $theDate #display system information echo System Information $info #display user id echo $user #display current directory echo Current Directory is $PWD Output Source is as follows: centertop Linux Script 3 #! /bin/bash getDate(){ date return } hostname=$(hostname) theDate=$(getDate) args=("$@") size=${#args} if then echo You need to enter two arguments exit 64 elif then echo You need to enter two arguments exit 64 elif then echo ${args} ${args} fi #display date echo $theDate #display username echo $USER #display hostname echo $hostname Output is as follows: 251642-76352 Linux Script 4 #!/bin/bash getDate(){ date return } theDate=$(getDate) users=$(who --count) path=$PATH echo a. Windows echo b. Linux echo c. Mac OS echo d. Chrome OS read -p "Enter An Answer: " choice case $choice in "a") echo "Windows is the most popular OS in the world.";; "b") echo "Linux is the preferred choice for most developers.";; "c") echo
Leave feedback