-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE4_database.sh
More file actions
executable file
·45 lines (39 loc) · 849 Bytes
/
Copy pathE4_database.sh
File metadata and controls
executable file
·45 lines (39 loc) · 849 Bytes
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
#!/bin/awk
BEGIN{
OFS = sep = " " #设置输出字段分隔符
file2 = ARGV[2]
ARGV[2] = ""
eofstat = 1
if((ng = getgroup()) <= 0)
exit
}
{
while (prefix($0) > prefix(gp[1]))
if (( ng = getgroup() ) <= 0 )
exit
if ( prefix($0) == prefix(gp[1]) )
for ( i=1; i <= ng; i++ )
print $0, suffix(gp[i])
}
function getgroup(){
if ( getone(file2,gp,1) <= 0)
return 0
for ( ng = 2; getone(file2,gp,ng) > 0;ng++ )
if ( prefix(gp[ng]) != prefix(gp[1]) ){
unget(gp[ng])
return ng -1
}
}
function getone(f,gp,n){
if ( eofstat <= 0 )
return 0
if ( ungot ){
gp[n] = ungotline
ungot = 0
return 1
}
return eofstat = ( getline gp[n] < f )
}
function unget(s) { ungotline = s; ungot = 1 }
function prefix(s) { return substr(s, 1, index(s,sep) - 1) }
function suffix(s) { return substr(s,index(s, sep) + 1) }