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?



jkavxAsked:
Who is Participating?
 
nukeme369Connect With a Mentor Commented:
(the above is the script needed to generate the file list - working on the insert at %file part)
0
 
nukeme369Commented:
#!/bin/bash
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.

0
 
jkavxAuthor Commented:
If you can work out the insert at the specific file location piece, please add a comment with the details.  Thx.
0
All Courses

From novice to tech pro — start learning today.