0

For example, I have a code can find me the directory name in the current folder without . in the front:

find . -maxdepth 1 -type d -regex '\./[^.]*$'

However, it gives me

./Templates
./eclipse-workspace
./Public
./Documents
./VirtualBox VMs
./Videos
./CLionProjects
./jd2

I need to do

du -sh

for each line of them sequentially, how can I do?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

1

While there is a -exec command built into find, it is difficult to use (see Why does find -exec mv {} ./target/ + not work ? (on cygwin)).

What you are looking for is this pipe command:

find . -maxdepth 1 -type d -regex '\./[^.]*$' | cut -c 3-

Anytime the find command output something, the cuts happen.

NVRM
  • 11,480
  • 1
  • 88
  • 87