-
Notifications
You must be signed in to change notification settings - Fork 0
/
all.sh
51 lines (49 loc) · 777 Bytes
/
all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
indir=$1
outdir=$2
space=" "
prefix="./run.sh"
rm temp.txt
:'
for i in `find $1 -name "reco*" -type f`; do
filename="${i##*/}"
temp=${i#"$1"}
test=${temp//$filename}
final=$2$test
output=$prefix$space$i$space$final
#$output
echo $output >>temp.txt
done
'
for i in `find $1 -name "reco*" -type f`; do
output=$prefix$space$i$space$2
#$output
echo $output >>temp.txt
done
for i in {0..119}
do
dir=$2$i
mkdir -p $dir
done
open_sem(){
mkfifo pipe-$$
exec 3<>pipe-$$
rm pipe-$$
local i=$1
for((;i>0;i--)); do
printf %s 000 >&3
done
}
run_with_lock(){
local x
read -u 3 -n 3 x && ((0==x)) || exit $x
(
"$@"
printf '%.3d' $? >&3
)&
}
N=8
open_sem $N
cat temp.txt | while read p
do
run_with_lock $p
done