如何在 ubuntu 中逐行流水线
How to pipeline in a line by line fashion in ubuntu
例如,我有一个代码可以找到我当前文件夹中的目录名称而不需要。在前面:
find . -maxdepth 1 -type d -regex '\./[^.]*$'
然而,它给了我
./Templates
./eclipse-workspace
./Public
./Documents
./VirtualBox VMs
./Videos
./CLionProjects
./jd2
我需要做
du -sh
每行按顺序,我该怎么办?
虽然 find 中内置了一个 -exec 命令,但很难使用(参见 Why does find -exec mv {} ./target/ + not work ? (on cygwin))。
您正在寻找的是这个管道命令:
find . -maxdepth 1 -type d -regex '\./[^.]*$' | cut -c 3-
任何时候 find 命令输出一些东西,cuts 就会发生。
例如,我有一个代码可以找到我当前文件夹中的目录名称而不需要。在前面:
find . -maxdepth 1 -type d -regex '\./[^.]*$'
然而,它给了我
./Templates
./eclipse-workspace
./Public
./Documents
./VirtualBox VMs
./Videos
./CLionProjects
./jd2
我需要做
du -sh
每行按顺序,我该怎么办?
虽然 find 中内置了一个 -exec 命令,但很难使用(参见 Why does find -exec mv {} ./target/ + not work ? (on cygwin))。
您正在寻找的是这个管道命令:
find . -maxdepth 1 -type d -regex '\./[^.]*$' | cut -c 3-
任何时候 find 命令输出一些东西,cuts 就会发生。