Open a text file in terminal
sudo gedit logged.sh
copy and paste the following lines
#!/bin/bash
# Write a shell script called hello which output the following:
# + Your username
# + The time and date
# + Who is logged on
# + also output a line of asterices (*******) after each section
# function to display a line of asterices
function line(){
echo "*************************************************"
}
echo "Your username : $(echo $USER)"
line # call function
echo "Current date and time : $(date)"
line
echo "Currently logged on users:"
who
line
Then save and exit
In terminal type the following command
sudo chmod +x logged.sh
./logged.sh
The out put is

2 comments:
./loggedsh ==>./loggde.sh
Thanks to your comments
Post a Comment