"find" output relative to directory

cd into the directory first:

cd diskimg && find . 

On completion, you will be back in your root directory.

Your files will be prepended with ./ in this case; the only way I see around that would be using cut:

{ cd diskimg && find .; } | tail -n +2 | cut -c 3-

Use a subshell to avoid changing your shell's current directory (this isn't necessary if you're piping the output as the left-hand side of a pipe already runs in a subshell).

(cd diskimg && find .)

Another, more complex but only using find approach from my other answer:

find diskimg -mindepth 1 -printf '%P\n'

If what you are trying to do is not too complex, you could accomplish this with sed:

find diskimg | sed -n 's|^diskimg/||p'

Or cut:

find diskimg | cut -sd / -f 2-

Tags:

Find