What programming facilities does a shell provides?
Asked by francisca
(33 points)
on Aug 3, 2009
under Internet & Computers
1 answers
What programming facilities does a shell provides?

![]() Nadeem (120 points) |
on Aug 3, 2009If you have ever coded a batch (bat) file on a windows operating system, you can consider yourself a shell scripter. Shell scripts are the counterparts of batch files on the *nix O/S, although the power of *nix scripts surpasses those of windows. Besides being the interpreter of your commands that you type in it, the shell has some additional responsibilities when viewed as a programming environment. These are noted below: Program Execution The shell has its own built-in programming language. This language is interpreted, meaning the shell analyzes each statement in the language one line at a time and then executes it. Programs developed this way are easier to code and debug. The shell programming language provides features you’d find in most other programming languages; it has looping constructs, decision-making statements and is procedure (function) oriented. However, the standard shells also lack many features such as arrays, data typing and built-in arithmetic operations. The Korn shell is much closer to traditional structured programming language, providing some limited data types (including integers and arrays) and built-in integer arithmetic. Shell scripts have the following advantages: Here are some features that can help you immensely during your use of the shell itself. The shell stores a list of the commands that you have issued. You can navigate up and down through this list using the Up and Down Arrow keys. To repeat the last command is just Up Arrow, Enter. nix can have some outrageously long file names, which is great when you're reading them in a list, but it is another matter when you have to type it on the command line. To make the user’s life easy, the programmers of the shells have provided a nifty little feature. Type the first letter or two and then press the Tab key. The shell will try to complete your command. If you typed enough letters to uniquely identify the file name, the shell fills the rest in for you. If the letters match multiple file names, the shell will fill in everything up to the point where they differ and wait. Hit Tab again and it will give you a list of possibilities. The shell will also help you complete path names. Let’s take a look at what file permissions are. *nix O/S are multi-user systems. To protect individuals and their private data, a secure file system had to be implemented. A method had to be devised to protect the users from each other. After all, you could not allow the actions of one user to crash the computer, nor could you allow one user to interfere with the files belonging to another user. Each file and directory on your system is assigned access rights for the owner of the file, the members of a group of related users, and everybody else. Rights can be assigned to read a file (r), to write a file (w), and to execute a file (x) (i.e., run the file as a program). To see the permission settings for a file, we can use the ls command as follows: We will concentrate on the first portion of the output i.e. the –rwxrwxrwx string and how to interpret it. It is easy to think of the permission settings as a series of bits. Here's how it works: rwx rwx rwx = 111 111 111 rwx = 111 in binary = 7 The command to change permissions regarding a file is chmod. Here is a sample usage: |
|

