Write a shell script that outputs the name of the shell executing it.
What will be an ideal response?
There are many ways to solve this problem. The following solutions are all
basically the same. These scripts take advantage of the PPID shell variable,
which holds the PID number of the shell that is the parent of the process
using the variable. They also use the fact that echo changes multiple sequen-
tial SPACEs to a single SPACE. The cut utility interprets multiple sequential SPACEs
as multiple delimiters, so the script does not work properly without echo.
$ cat a
pid=$PPID
line=$(ps | grep $pid)
echo $line | cut --delimiter=" " --fields=4
$ cat a2
pid=$PPID
echo $(ps | grep $pid) | cut --delimiter=" " --fields=4
$ cat a3
echo $(ps | grep $PPID) | cut --delimiter=" " --fields=4
The easy solution is to give the following command:
$ echo $0
The $0 is the first command-line token, which is usually the name of the
script or program that is running (page 1133). In some cases, such as when
you call the script with a relative or absolute pathname, this outcome might
not be exactly what you want.
You might also like to view...
You can press the ____ keys to duplicate a selected page.
A. Ctrl+C B. Ctrl+D C. Ctrl+X D. Alt+C
A CSS style rule has ____ parts.
A. one B. two C. three D. four
HTML is a document that uses rules to standardize the appearance of webpage content such as font, margins, and background colors.
Answer the following statement true (T) or false (F)
Which of the following statements is not true about importing an Excel spreadsheet into Access?
A. You have less control over the imported data. B. It will make the database file size larger. C. There will be no dependency between the imported data and the original Excel sheet. D. You have more control over the imported data.