Given a directory, get relative paths of all files recursively

0

I'm building an RPM spec file and need to list in the %files section the files to include, relative to a build root that I'll specify. I already have the assembled directory that needs to be packaged--I just need to turn this into a list of relative paths to all files contained therein.

To do this I'm currently using find, but it's returning absolute paths.

find $1/codebase -type f ! -name ".*" >> ${BUILD_RPM_DST_DIR}/rpm.spec

I'm a bit of a unix n00b so I apologize.

Should I pipe it to sed or grep and remove the initial portion of the path? A sample of how to do that would be helpful.

devios1

Posted 2012-12-10T23:07:33.533

Reputation: 685

Answers

1

Find will give you relative paths, if you pass a relative specification to it when you run it. You are passing $1/codebase which I gather is an absolute path. Instead of using that command try something like cd $1/codebase ; find . -type ... instead.

Zoredache

Posted 2012-12-10T23:07:33.533

Reputation: 18 453