The (…) and { …; } Constructs in Unix Shell script
Sometimes you may want to group a set of commands together for some reason. For example, you may want to send a sort followed by execution of your plot data program into the background for execution....
View ArticleHow to "send" variable to sub-shell ?
Another Way to Pass Variables to a Subshell If you want to send the value of a variable to a subshell, there’s another way to do it besides setting the variable and then exporting it. On the command...
View ArticleStart up files for ksh – The Korn shell .profile and .kshrc
In “What Is the Shell?,” you learned about the login sequence. This sequence is completed when your shell displays your command prompt and waits for you to type your first command. Just before it does...
View ArticleUnix Interview Questions and Answers – Part 1
What is a Make file? Make file is a utility in Unix to help compile large programs. It helps by only compiling the portion of the program that has been changed Could you tell something about the Unix...
View ArticleUnix Interview Questions and Answers – Part 2
Explain kill() and its possible return values. What does the command “ $who | sort –logfile > newfile” do? What are shell variables? Shell variables are special variables, a name-value pair created...
View ArticleUnix Shell Scripts – Example 1
Write a shell script sum.sh that takes an unspecified number of command line arguments (up to 9) of ints and finds their sum. Modify the code to add a number to the sum only if the number is greater...
View ArticleUnix Shell Scripts – Example 2
Write a shell script takes the name a path (eg: /venkat/wikiconsole/material/handin ), and counts all the sub directories (recursively). Ans: #! /bin/sh<span style="font-size: small; color:...
View ArticleUnix Shell Scripts – Example 3
Write a shell script that takes a file where each line is given in the format: F08, Venkat, Suman, Karthy, SCS, CSD, 3, L, 4, 15123 , V ,, Creates a folder for each user name (eg: Venkat) and set the...
View ArticleUnix Shell Scripts – Example 4
Write a shell script that takes a name of a folder as a command line argument, and produce a file that contains the names of all sub folders with size 0 (that is empty sub folders) #! /bin/sh ls $1 |...
View ArticleHow To Run a Script In Linux
There are two ways you can execute your shell scripts. Once you have created a script file: Method 1 Pass the file as an argument to the shell that you want to interpret your script. Step 1 : create...
View Article