我能够串行运行,但无法平行运行。我的代码如下:
#!/bin/bash
while :
do
for i in `find ~/Mainstore-1/ -maxdepth 1 -type f`
do
md5sum $i
done
sleep 1
done
这应该做:
find ~/Mainstore-1/ -maxdepth 1 -type f -print0 | while read -d '' -r file ; do
# launch md5sum in background using `&`
md5sum "$file" &
done
# Wait for workers to finish
wait