Create call tree for shell scripts
Please remember that this is the newbie forum.
My first question was declared not clear so an edit is merited. And edit again with this comment: I still may not have described this well so I will show my work so far. Note to readers: I have made major edits to this question so answers that look inappropriate were appropriate when I started this. There is a directory called MCS with multiple sub directories. Within those subdirectories are multiple script files. My understanding is that each of those scripts end with the phrase .sh. I need to discover which scripts are called by other scripts. Presume that t1.sh is called by t2.sh. The first tentative goal is to end up with a file that contains something like: t1.sh is called by t2.sh t6.sh t2.sh is called by t7.sh In my bash script I have Quote:
Quote:
So, to the best of my ability: How do I pipe a list of file names with full path into baseline and get the file name out? Keeping the .sh is preferred but I will take what I can get. |
You'll need explain more what you're doing. "There's a bunch of scripts that call each other" just doesn't mean much.
|
so you got a bunch of scripts and within them scripts they call another script. Now you're hoping there is an easy way to run a program that will figure out what scripts call which scripts and put them in a list of some sort.
Quote:
I do not think there is an easy way. Code:
find /path -type f -iname "*.sh" > firstList there is more than one way to do this. Code:
grep -rwn /path or /file -e "pattern" |
AwesomeMachine (Edit add: and also BW-userx) are correct, you'll have to describe your intentions more clearly. However I wonder that once you do, you'll no longer have a question.
Never tried exactly this, but find can -exec what it finds. I use the -exec option a ton, but usually to mv, cp, or rm or something, not directly execute a found file, but .... why not? Do a quick test. As far as filtering what you want and don't want, find will also do that by way of filename search string criteria and/or exclude filters (which I rarely use, but they are supported). The next problem becomes if any of these scripts require passing arguments. And then my whole background thought of, "I would not search my system for .sh files and then run them all!" Or at the very least I'd do a dry run and verify the list of what I found matched what I intended for the result. Additional edit: What BW-userx is talking about is something I've done and why I've learned to use the -exec option of find 'ere long ago: Code:
find . -name "pattern" -exec grep <string> {} /dev/null \; |
Milestones are rather slow for me. This script
Quote:
It then shows all the files names without the paths in the terminal window. I have not been able to send that output of just the file names to file list2.txt so I can then work that list. Quote:
|
here try this you'll have to add in what your looking for
Code:
#!/bin/bash Code:
echo "$LINE" >> text2 or if you just want to consolidate the matches in one directory. Code:
#!/bin/bash Code:
$ ./findstuff |
Here I reread your Conditions, and rewrote this script, it may or may not work, depending on how you actually have you scripts set up. it might look complicated but its not.
Code:
|
All times are GMT -5. The time now is 08:43 PM. |