forked from CMSROMA/Utilities
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathremove_dup.sh
executable file
·53 lines (42 loc) · 1.02 KB
/
remove_dup.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
52
#!/bin/bash
file=$1
cat > remove_dup.awk <<EOF
BEGIN{
old=0;
new =0;
line="";
}
(NR!=0){
if(match($0,"[0-9]*_[0-9]*_[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]\.root")){ # if the file is a typical castor output
end=substr($0,RSTART);
n = split(end, end_, "_");
# print n, $0;
# print end_[1], end_[2], end_[3];
if(match(end_[3],"[a-zA-Z]+.*\.root")){ # se soddisfa anche a questa,
# allora e' prodotto da crab server
if(end_[1]!=old){
print line
old=end_[1];
new =end_[2];
line = $0;
} else {
#print end_[1], end_[2], end_[3];
if(end_[2]>=new){
string1="basename "line
string2="basename "$0
string2 | getline filename_new
string1 | getline filename_old
print "[STATUS] removing "filename_old" as duplicate of "filename_new"" > "/dev/stderr"
new = end_[2];
line = $0;
}
}
} else print $0
} else print $0
}
END{
if(line!="") print line
}
EOF
awk -f remove_dup.awk $file | sed '/^$/ d'
rm remove_dup.awk