ITeye博客

shell scripting

standalone · 2010-01-06 14:59 · linux · 编程语言 · Markdown

1. How do you find out what抯 your shell?

Operating System/Shell Scripting

echo $SHELL


2. How do you fire a process in the background?

Operating System/Shell Scripting

./process-name &


3. How do you refer to the arguments passed to a shell script?

Operating System/Shell Scripting

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


4. What抯 the conditional statement in shell scripting?

Operating System/Shell Scripting

if then ?fi


5. How do you do number comparison in shell scripts?

Operating System/Shell Scripting

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


6. How do you test for file properties in shell scripts?

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?

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?

Operating System/Shell Scripting

$#


9. What抯 a way to do multilevel if-else抯 in shell scripting?

Operating System/Shell Scripting

if then elif fi


10. How do you write a for loop in shell?

Operating System/Shell Scripting

for in do done

11. How do you write a while loop in shell?

Operating System/Shell Scripting

while do done


12. How does a case statement look in shell scripts?

Operating System/Shell Scripting

case in ) ;; ) ;; esac


13. How do you read keyboard input in shell scripts?

Operating System/Shell Scripting

read


14. How do you define a function in a shell script?

Operating System/Shell Scripting

function-name()


15. How do you stop all the processes, except the shell window?

Operating System/Shell Scripting

kill 0


16. How do you find out about all running processes?

Operating System/Shell Scripting

ps -ag


17. How do you stop a process?

Operating System/Shell Scripting

kill pid


18. What抯 the command to find out today抯 date?

Operating System/Shell Scripting

date


19. What抯 the command to find out users on the system?

Operating System/Shell Scripting

who


20. How do you find out the current directory you抮e in?

Operating System/Shell Scripting

pwd

21. How do you remove a file?

Operating System/Shell Scripting

rm


22. How do you remove recursively?

Operating System/Shell Scripting

rm -rf


23. How do you find out your own username?

Operating System/Shell Scripting

whoami


24. How do you send a mail message to somebody?

Operating System/Shell Scripting

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


25. How do you count words, lines and characters in a file?

Operating System/Shell Scripting

wc


26. How do you search for a string inside a given file?

Operating System/Shell Scripting

grep string filename


27. How do you search for a string inside a directory?

Operating System/Shell Scripting

grep string *


28. How do you search for a string in a directory with the subdirectories recursed?

Operating System/Shell Scripting

grep -r string *


29. What are PIDs?

Operating System/Shell Scripting

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


30. How do you list currently running process?

Operating System/Shell Scripting

ps

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。