How to run a command (1000 times) that requires two different types of input files

后端 未结 3 949
青春惊慌失措
青春惊慌失措 2021-01-17 03:56

I have calculated directed modularity by means of DirectedLouvain (https://github.com/nicolasdugue/DirectedLouvain). I am now trying to test the significance of the values o

3条回答
  •  再見小時候
    2021-01-17 05:03

    1. Find all files with that extension.
    2. For each file
      1. Extract the filename without exntesion
      2. Run the command

    So:

    find -type f -name '*.ext' |
    while IFS= read -r file; do
       file_no_extension=${file##*/};
       file_no_extension=${file_no_extension%%.*}
       ./convert -i "$file" -o "$file_no_extension".bin -w "$file_no_extension".weights
    done
    
    // with find:
    find -type f -name '*.ext' -exec sh -c 'f=$(basename "$1" .ext); ./convert -i "$1" -o "$f".bin -w "$f".weights' _ {} \;
    
    // with xargs:
    find -type f -name '*.ext' |
    xargs -d '\n' -n1 sh -c 'f=$(basename "$1" .ext); ./convert -i "$1" -o "$f".bin -w "$f".weights' _
    

提交回复
热议问题