Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Tuesday, June 5, 2012

Can a shell script set environment variables of the calling shell?


I'm trying to write a shell script that, when run, will set some environment variables that will stay set in the caller's shell.

BASH: Possible to abort shell script if any command returns a non-zero value?


I have a Bash shell script that invokes a number of commands. I would like to have the shell script automatically exit with a return value of 1 if any of the commands return a non-zero value.

Friday, June 1, 2012

unix shell script find out which directory the script file resides?


Basically I need to run the script with paths related to the shell script file location, how can I change the current directory to the same directory as where the script file resides?

Wednesday, May 30, 2012

Best way to kill all child processes


I basically want to kill a whole process tree. What is the best way to do this using any common scripting languages. I am looking for a simple solution.

Monday, May 21, 2012

Why doesn"t "cd' work in a bash shell script?


I'm trying to write a small script to change the current directory to my project directory:

In the bash script how do I know the script file name?


How can I determine the name of the bash script file inside the script itself?

How do I prompt for input in a Linux shell script?


I want to pause input in a shell script, and prompt the user for choices. The standard 'Yes, No, or Cancel' type question. How do I accomplish this at a typical bash prompt?

Sunday, May 20, 2012

Friday, May 18, 2012

How to count all the lines of code in a directory recursively?


We've got a PHP application and want to count all the lines of code under a specific directory and its subdirectories. We don't need to ignore comments, as we're just trying to get a rough idea.