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
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbHwGTWJ-xGEbWdlI5OjBrWN5dwKkmjmNThD0TtBxwuYL8twVApfXV7YI2XHoUCMBFGMIx15_z-Qu89xKVf4C86aRa2_LihrvoueYR9_n6WtpdNIHoXhQFS4ymIO4kDXZB3FkagaJ-6M0/s320/Selection_006.png)
2 comments:
./loggedsh ==>./loggde.sh
Thanks to your comments
Post a Comment