I'm new to awk.
im using an executable awk script to process a master file.
I run awk on this master file and form a variable which is a string representing the full path to another file, say file 2.
Once obtaining this new files path, stored in a variable, I wish to perform additional awk processing on this file 2. How do I do that?
1) I need to process the contents of file 2, so I believe I need to re-awk it. 2) alternatively, I need to open this file and continue performing awk processing on it like matches
---- edit for additional info ---
The master file contains ultimately many paths which require additional processing, not just a single file path. In total, there are 3 nested levels of file paths.
- for example: master.file-->nest2-->nest3
master.file(EG: we find 10 paths)-->nest2 (each of the 10 files need to be awk'd and individually contain 5 paths. in total there are now 5*10 files to awk)-->nest3 (here i am now performing awk on each one.)
At each level, multiple file paths exist which all need to be opened for more processing. This creates a spider web of paths. Thus, i am doing this as an executable awk script acting first on the master file as the nested paths must be formed through iteration starting at the top, or master file.
in my first awk script, processing the master.file, awk is by default going line by line. Once it finds a match, which is my file path #1 for example, how do i open this new file or re-awk it to continue to nest2 and nest3?
Here is the code from my awk script acting on the master.file
BEGIN {
# set the field seperator
FS=".";
# declare the basepath to files we're trying to locate and their extension
basepath = "/home/myscratch";
exten = ".txt";
}
# first locate all lines that are an include line
/^.in/ {
# concat the the basepath to the relative path+filename and append file extension for full path = mypath
mypath = basepath$3exten;
# we are only looking for includes pointing to specific_folder_NAME
if (mypath ~ /[/]specific_folder_name[/]/) {
# saving the full paths from the master.file
print mypath > "awk_master_includes.txt"
# Not sure if i should re-awk with system, but seems incorrect or better way.
# What i really want to do, is within this if-statement, to open the file stored in mypath above
#system("awk -f ./command2.awk $mypath")
}
}