Bash multiple files processing

前端 未结 5 1759
感动是毒
感动是毒 2021-01-23 19:21

I have a file named data_file with data: london paris newyork italy...50 more items

Have a directory with over 75 files, say dfile1, dfie2...afle75 in which i am perform

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-23 20:25

    Using GNU Parallel you can do something like this:

    doit() {
        f="$1"
        line="$2"
        found=$(grep $line $f)      
    
        if [ ! -z "$found" ]; then
          perform task here
        fi
    }
    export -f doit
    
    find . -type f | parallel doit :::: - data_file
    

提交回复
热议问题