jkavx
asked on
Modify file with directory structure details
I need to take an existing file, an rpm spec file, and insert a list of files at a specific point. The spec file will have something like this as the demarcation of where the file list needs to be inserted:
%file
The script needs to take a directory and recursively identify all files under that directory and write each file, and its path, on a separate line in the rmp spec file.
What would be the best way to handle this?
%file
The script needs to take a directory and recursively identify all files under that directory and write each file, and its path, on a separate line in the rmp spec file.
What would be the best way to handle this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If you can work out the insert at the specific file location piece, please add a comment with the details. Thx.
workingdir=`pwd`
for filelist in *
do echo $workingdir"/"$filelist >>/tmp/rpmspecfile
done
Fairly self explanatory, but I'll walk through it.
Variable named workingdir is defined with the current directory as its data.
for loop - looping through each file in current directory.
each file has the following happen:
the $workingdir variable is echoed, with a trailing / then the current file is written to /tmp/rpmspecfile.
Repeat for every file in the current dir.