- 论坛徽章:
- 0
|
- [root@vh122 awk]# tree /mnt/awk
- /mnt/awk
- ├── folder1
- │ ├── 1.txt
- │ ├── 2.txt
- │ └── 3.txt
- ├── folder2
- │ ├── 1a.txt
- │ ├── 2a.txt
- │ └── 3a.txt
- └── test.awk
- /mnt/awk/test.awk
- #!/usr/bin/awk -f
- BEGIN{
- path1="/mnt/awk/folder1"
- path2="/mnt/awk/folder2"
- cmd1=sprintf("cat `ls %s/*.txt`",path1)
- while(cmd1|getline > 0)
- f1[$0]
- while("ls "path2|getline file > 0){
- j=0
- cmd2=sprintf("cat %s/%s",path2,file)
- while(cmd2|getline > 0){
- if(!($0 in f1))
- f2[++j]=$0
- }
- cmd3=sprintf("> %s/%s",path2,file)
- system(cmd3)
- for(i=0;++i<=length(f2);){
- cmd4=sprintf("echo %s >> %s/%s",f2[i],path2,file)
- system(cmd4)
- }
- delete f2
- }
- }
复制代码 |
|