
- Forum
- Operating Systems
- Shell Programming
- Shell programming
Shell programming
This is a discussion on Shell programming within the Shell Programming forums, part of the Operating Systems category; How can I manually program the shell? It would be interesting to write some custom scripts for me. Anyone expert ...
-
Shell programming
How can I manually program the shell? It would be interesting to write some custom scripts for me. Anyone expert on this? Thanks!
-
Shell scripting is necessary for automating a broad range of administration tasks on servers related to UNIX and Linux Operating system. These scripts can be run manually to combine many steps into a single command. I have given below a simple shell script written manually to replace the command
find . -name file -print
% cd ~/bin
% emacs sfind
% page sfind
find . -name $1 -print
% chmod a+x sfind
% rehash
% cd /usr/local/bin
% sfind tcsh
./shells/tcsh
-
So is it that shell scripts are multiple commands which are entered manually by user at a command line interface. From the above I get the idea that shell scripts are executable files. Am I right?
-
I have given below some hints and guidelines for you to try the shell scripting progra suggested by our friend. These are the steps needed to write and execute a shell script.
* Open the file using an editor like "vi"
like vi sfind.sh
* All shell scripts should begin with "#!/bin/bash" that is as given in the example depending upon the shell used by user.
* Write the script fully in the file opened
* The next step is to make the script executable by using the "chmod" command.
as done in the example as
% chmod a+x sfind
* Then execution of script is done by entering the name of the script on the
command line, preceded by its path. If it is current directory then
./followed by shell filename.sh would suffice.
Try and let us know whether you were successful in running the script.
-
Unix is the Best
Alexia,
The most interesting thing with Unix O/S is the scripting aspect of it. U can manually write scripts that does so many things u can imagine.
-
Sponsored Ads

Reply With Quote





