Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to list all scripts (recursively) which are being called by a master script. For example: >> this script calls,, etc >> this one calls,,, > similarly.

This is like the tree command for scripts.

The output could be like
share|improve this question
Thanks for formatting. – Pandoo Jan 11 '13 at 18:22
If you really don't find anything else, you could always add things into your scripts (or making a copy) that say "if(you're being called by script:check_script_tree) { display the name of this script; call scripts; } else { do the script normally; }". A huge pain, but well, if you're desperate, you can do that. My teacher calls it making a program's skeleton. But there's probably something easier. – Ariane Jan 11 '13 at 18:25
Yeah, I did not find anything else. It was mentioned somewhere to add "echo $0 > somefile.log" to all scripts, just to get a list of the files. That would be insane. – Pandoo Jan 11 '13 at 18:30
up vote 1 down vote accepted

The best way to do this is pstree. It will list all running processes in a nice tree format. You can use the -H option to highlight a specific command (given as a PID). In the example below I am using pgrep to get the PID of :

pstree -H `pgrep` |grep -A 2 
 |                  |
 |                  |

The ps command can also do what you need, the ps command can do everything except brew a good cup of coffee:

ps xjf

This will list all processes launched by (in fact, it will list all processes, including those launched by in a tree-like format:

|   \_
|       \_
|       \_
|   \_
|   \_

I am only showing the relevant output here, the above command will also give you various other pieces of information such as the PID, process status etc etc.

share|improve this answer
Yeah it works. Wow. Thanks. – Pandoo Jan 14 '13 at 18:42
Yup, the standard UNIX tools are impressive if cryptic. If you have nothing better to do over the next weekend and can't find "War and Peace", try reading through the 1230 lines of man ps :). – terdon Jan 14 '13 at 18:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.