Skip to main content
explain how to modify for different depth.
Source Link
derobert
  • 113.2k
  • 20
  • 242
  • 289

find + awk approach for your current folder structure /home/myuser/parent1/<folder>:

find /home/myuser/parent1 -type f -name "*.png" \
     | awk -F'/' '{ a[$5]++ }END{ for(i in a) print i,a[i] }'
  • $5 - points to a folder name at the needed level (adjust this if your folder structure is different; it should be two more than directory depth of the parent. (So for /tmp/parent1 it'd be $4, and for /home/myuser/Documents/parent1 it'd be $6).

find + awk approach for your current folder structure /home/myuser/parent1/<folder>:

find /home/myuser/parent1 -type f -name "*.png" \
     | awk -F'/' '{ a[$5]++ }END{ for(i in a) print i,a[i] }'
  • $5 - points to a folder name at the needed level

find + awk approach for your current folder structure /home/myuser/parent1/<folder>:

find /home/myuser/parent1 -type f -name "*.png" \
     | awk -F'/' '{ a[$5]++ }END{ for(i in a) print i,a[i] }'
  • $5 - points to a folder name at the needed level (adjust this if your folder structure is different; it should be two more than directory depth of the parent. (So for /tmp/parent1 it'd be $4, and for /home/myuser/Documents/parent1 it'd be $6).
added 66 characters in body
Source Link
RomanPerekhrest
  • 30.9k
  • 5
  • 47
  • 68

find + awk approach for your current folder structure /home/myuser/parent1/<folder>:

find /home/myuser/parent1 -type f -name "*.png" \
     | awk -F'/' '{ a[$5]++ }END{ for(i in a) print i,a[i] }'
  • $5 - points to a folder name at the needed level

find + awk approach:

find /home/myuser/parent1 -type f -name "*.png" \
     | awk -F'/' '{ a[$5]++ }END{ for(i in a) print i,a[i] }'
  • $5 - points to a folder name at the needed level

find + awk approach for your current folder structure /home/myuser/parent1/<folder>:

find /home/myuser/parent1 -type f -name "*.png" \
     | awk -F'/' '{ a[$5]++ }END{ for(i in a) print i,a[i] }'
  • $5 - points to a folder name at the needed level
added 1 character in body
Source Link
RomanPerekhrest
  • 30.9k
  • 5
  • 47
  • 68

find + awk approach:

find /home/myuser/parentparent1 -type f -name "*.png" \
     | awk -F'/' '{ a[$5]++ }END{ for(i in a) print i,a[i] }'
  • $5 - points to a folder name at the needed level

find + awk approach:

find /home/myuser/parent -type f -name "*.png" \
     | awk -F'/' '{ a[$5]++ }END{ for(i in a) print i,a[i] }'
  • $5 - points to a folder name at the needed level

find + awk approach:

find /home/myuser/parent1 -type f -name "*.png" \
     | awk -F'/' '{ a[$5]++ }END{ for(i in a) print i,a[i] }'
  • $5 - points to a folder name at the needed level
Post Undeleted by RomanPerekhrest
deleted 8 characters in body
Source Link
RomanPerekhrest
  • 30.9k
  • 5
  • 47
  • 68
Loading
Post Deleted by RomanPerekhrest
Source Link
RomanPerekhrest
  • 30.9k
  • 5
  • 47
  • 68
Loading