I'd like to use find
to list all files and directories recursively in a given root for a cpio
operation. However, I don't want the root directory itself to appear in the paths. For example, I currently get:
$ find diskimg
diskimg
diskimg/file1
diskimg/dir1
diskimg/dir1/file2
But, I'd like to get
file1
dir1
dir1/file2
(note the root is also not in my desired output, but that's easy to get rid of with tail
).
I'm on OS X, and I'd prefer not to install any extra tools (e.g. GNU find) if possible, since I'd like to share the script I'm writing with other OS X users.
I'm aware this can be done with cut
to cut the root listing off, but that seems like a suboptimal solution. Is there a better solution available?
find diskimg/* | cut -d '/' -f2-
– nik.shornikov Jan 02 '17 at 16:54cut -c9-
should be faster – milahu Mar 15 '22 at 16:11