Q. How do I use bash shell? What command I need to type use bash shell?
A. GNU Bourne-Again Shell is default shell on most Linux systems (distributions). So when you open terminal from X Windows (KDE/Gnome) you directly opens a bash shell. Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file.
To find out your shell version type:
$ echo $SHELL
If you are using different shell, just type bash at command prompt and load bash shell:
How do I recursively grep through all sub-directories and find files containing given text / string or words?
Q. I am able to write PHP or Perl script where I can find out time difference between script executions. Now I have .shtml file that is nothing but a shell script outputting some data to browser. What I want is time difference or time it took to execute a script. How do I write a shell script?
A. Your Logic should be as follows:
* Get start time and store to a variable START
* Execute a shell script
* Grab output and send to web browser
* Get time again and store to a variable END
* Calculate difference using expression END – START
Shell script o get the time difference
Here is small script that does the same thing (please note that script teated on GNU/Linux and with GNU date command only):
$ vi timediff.bash
Append text as follows:
# do something
# start your script work here
ls -R /etc > /tmp/x
rm -f /tmp/x
# your logic ends here
DIFF=$(( $END - $START ))
echo "It took $DIFF seconds"
Save and execute the script as follows:
$ chmod +x timediff.bash
Execute the script:
It took 4 seconds
ow do I find the largest top files and directories on a Linux or Unix like operating systems?
How do I send an email using command line under Linux?