Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .