Bash input for multiple file

后端 未结 5 1873
一个人的身影
一个人的身影 2021-01-23 17:06

I have thousands of two set of files one with name.ext and another files name ending with name.ext.in, so for every name.ext there is a name.ext.in and now i have to pass this a

相关标签:
5条回答
  • 2021-01-23 17:33

    Judging from the comments to the other answers, you probably want something like this:

    for file in *.ext; do
        customise.pl "$file" "${file%.*}.new.psl"
    done
    

    The ${file%.*} syntax substitutes only the part of $file up until its last dot. You can check the manpages for Bash or Dash for more information on it if you need.

    0 讨论(0)
  • 2021-01-23 17:35

    another way.

    ls *.ext |xargs -i customise.pl {} {}.in
    
    0 讨论(0)
  • 2021-01-23 17:41

    I guess the simplest form is

        for f in "*.ext"
        do                 
             customise.pl  $f.ext $f.ext.in      
        done
    

    OUTPUT:

    0 讨论(0)
  • 2021-01-23 17:43

    If you want to run customise.pl for each pair of files, you can do it like this in a bash script:

    #!/bin/bash
    
    for i in `ls *.ext`
    do
      customise.pl $i $i.in
    done
    
    0 讨论(0)
  • 2021-01-23 17:53
    for i in *.ext; do 
        customise.pl "$i" "$i.in"
    done
    
    0 讨论(0)
提交回复
热议问题