Search a directory for files that contain pathnames

Hello, I really don't know if this is possible, but I figured the wonderful users of unix.com may be able to provide me with some help/suggestions.

I want to create a (bash) script that would go will accept an input file. That input file contains important information as well as pathnames. For example,

filler
filler
path/to/file2.txt
filler

For the filler information, I need to parse (which I have already done). However, if the script sees that one of the lines is a pathname, go to that file, and repeat the process.

Therefore, file1.txt would see "path/to/file2.txt" and go to that file. File2 would then be parsed to see if it contains any pathnames etc. This repeats until no more paths are found. Is this possible?

edit- This was posted in Unix of Advanced & Expert Users by mistake. Sorry for the error!

Hoping I understand your problem...

I think you should use either a while loop to awk to figure this out since you would have to go line by line. For example, the script would look at line one. If it contains "useful" information, save it. Otherwise it's a line which contains a path. In that case, go to that file and repeat the process.

Maybe others here can be more of help. I'm just not too familiar with awk to provide a solid answer.

This could be done with a simple recursive function, what did you try so far?

so far, I've written a script to grab the data I need. For the pathnames, I was thinking about storing them as variables.

while read line
do
if [["$line" == /]] ; then
	var1=$line
fi
done < infile

var1 would then have to get looped again somehow. Am I going about this all wrong?

This the way to read line in a file ( the syntax would require proper spacing around the brackets though).. you would need to specify a pattern instead of a single slash, and does it need to have a path or could it be located in the current directory (then it would necessarily have a /)?

Also, you would need to check if the file exist and if it is readable. You could put it in a variable, but what do you need to do with it? Perhaps you only need to print it, then it would not be necessary..

What would you do if you found a new path in the file? It think a recursive function with local variables would be the way forward. That would be quite simple code and since you appear to be trying to teach yourself scripting, I would not want to spoil it for you..

Have fun,

S.