#!/bin/bash
echo "This is my Shell Script"
echo "Todays Date is"
date "+%m/%d/%y"
The first line of the script is to use bash shell. The shell ignores anything after #, but #! as a prefix to the name
#!/bin/bash
The shell scripting can be used to work smarter. Shell scripting is useful can be used for administration. It makes life easy for them. Let us see an example which is common task for system administrators.
#!/bin/sh
echo "####################################################" >/home/user/performance.log
echo "Top CPU Processes at `date`" >>/home/user/performance.log
echo "####################################################" >>/home/user/performance.log
echo "" >>/home/user/performance.log
echo "####################################################" >>/home/user/performance.log
echo "Top Command Results at `date`" >>/home/user/performance.log
echo "####################################################" >>/home/user/performance.log
echo "" >>/home/user/performance.log
top >> /home/user/performance.log
echo "####################################################" >>/home/user/performance.log
echo "Processes Running at `date`" >>/home/user/performance.log
echo "####################################################" >>/home/user/performance.log
ps -auxww >> /home/user/performance.log
echo "" >>/home/user/performance.log
echo "####################################################" >>/home/user/performance.log
top -n 5
top -n 5 | tail -7 | awk {'print $1,$9,$10,$11'}
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (2)
Commented:
- While these editors have advanced features, they also have a learning curve. For getting started I far prefer nano or pico, which are freely available if not already built-in.
To get to know the commands, refer to the manual pages for each command:
man [command name]
..or Google them.
Commented:
vi/vim are king for UNIX multiOS.