---
title: "shell scripting"
author: "standalone"
date: "2010-01-06T14:59:39Z"
tags: []
categories: ["编程语言"]
slug: "shell-scripting"
draft: false
lastmod: "2012-10-26T11:40:05Z"
id: 563987
url: "https://standalone.iteye.com/blog/563987"
---

1\. [How do you find out what抯 your shell?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-2.html)

Operating System/Shell Scripting

echo $SHELL

* * *

2\. [How do you fire a process in the background?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting.html)

Operating System/Shell Scripting

./process-name &

* * *

3\. [How do you refer to the arguments passed to a shell script?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-3.html)

Operating System/Shell Scripting

$1, $2 and so on. $0 is your script name.

* * *

4\. [What抯 the conditional statement in shell scripting?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-4.html)

Operating System/Shell Scripting

if then ?fi

* * *

5\. [How do you do number comparison in shell scripts?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-5.html)

Operating System/Shell Scripting

-eq, -ne, -lt, -le, -gt, -ge

* * *

6\. [How do you test for file properties in shell scripts?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-6.html)

Operating System/Shell Scripting

-s filename tells you if the file is not empty, -f file...

* * *

7\. [How do you do Boolean logic operators in shell scripting?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-7.html)

Operating System/Shell Scripting

! tests for logical not, -a tests for logical and, and ...

* * *

8\. [How do you find out the number of arguments passed to the shell script?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-8.html)

Operating System/Shell Scripting

$#

* * *

9\. [What抯 a way to do multilevel if-else抯 in shell scripting?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-9.html)

Operating System/Shell Scripting

if then elif fi

* * *

10\. [How do you write a for loop in shell?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-10.html)

Operating System/Shell Scripting

for in do done

11\. [How do you write a while loop in shell?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-11.html)

Operating System/Shell Scripting

while do done

* * *

12\. [How does a case statement look in shell scripts?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-12.html)

Operating System/Shell Scripting

case in ) ;; ) ;; esac

* * *

13\. [How do you read keyboard input in shell scripts?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-13.html)

Operating System/Shell Scripting

read

* * *

14\. [How do you define a function in a shell script?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-14.html)

Operating System/Shell Scripting

function-name()

* * *

15\. [How do you stop all the processes, except the shell window?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-15.html)

Operating System/Shell Scripting

kill 0

* * *

16\. [How do you find out about all running processes?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-16.html)

Operating System/Shell Scripting

ps -ag

* * *

17\. [How do you stop a process?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-17.html)

Operating System/Shell Scripting

kill pid

* * *

18\. [What抯 the command to find out today抯 date?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-18.html)

Operating System/Shell Scripting

date

* * *

19\. [What抯 the command to find out users on the system?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-19.html)

Operating System/Shell Scripting

who

* * *

20\. [How do you find out the current directory you抮e in?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-20.html)

Operating System/Shell Scripting

pwd

21\. [How do you remove a file?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-21.html)

Operating System/Shell Scripting

rm

* * *

22\. [How do you remove recursively?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-22.html)

Operating System/Shell Scripting

rm -rf

* * *

23\. [How do you find out your own username?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-23.html)

Operating System/Shell Scripting

whoami

* * *

24\. [How do you send a mail message to somebody?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-24.html)

Operating System/Shell Scripting

mail somebody@interviewduniya.com -s 慪our subject?-c ...

* * *

25\. [How do you count words, lines and characters in a file?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-25.html)

Operating System/Shell Scripting

wc

* * *

26\. [How do you search for a string inside a given file?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-26.html)

Operating System/Shell Scripting

grep string filename

* * *

27\. [How do you search for a string inside a directory?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-27.html)

Operating System/Shell Scripting

grep string *

* * *

28\. [How do you search for a string in a directory with the subdirectories recursed?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-28.html)

Operating System/Shell Scripting

grep -r string *

* * *

29\. [What are PIDs?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-29.html)

Operating System/Shell Scripting

They are process IDs given to processes. A PID can vary...

* * *

30\. [How do you list currently running process?](http://www.interviewduniya.com/OS-Interview-Questions/Shell-Scripting-Interview-Questions/Shell-Scripting-30.html)

Operating System/Shell Scripting

ps