Sample Header Ad - 728x90

What if I don't want to display the first directory in the find command?

0 votes
1 answer
120 views
I don't want to display the first directory component of paths printed by the inner find command from the below example
find . ! -name . -prune -type d -exec sh -c '
for dir do
echo "\n\n${dir#.*/}\n"
find "$dir" -exec md5sum {\} +
done' sh {} + >> ../md5
Output example:
dir1

md5sum value ./dir1/file1

dir2

md5sum value ./dir2/dir3/file2
I do not want to display the first directory component i.e ./dir1 and ./dir2 in the ./dir1/file1, ./dir2/dir3/file2 paths, instead I want find to print ./file1 and ./dir3/file2 Is there any way to do that? Thank you in advance
Asked by user27072144 (1 rep)
Oct 7, 2024, 07:53 PM
Last activity: Oct 8, 2024, 06:12 AM