Shell Script error: “head: invalid trailing option — 1”

后端 未结 3 552
旧时难觅i
旧时难觅i 2021-01-27 02:04

I have this code in my shell(bash) script for splitting a file into smaller parts:

for (( i=$start; i<=$lineCount; i=i+$interval))
do
    temp=`expr $i + $int         


        
3条回答
  •  佛祖请我去吃肉
    2021-01-27 02:52

    Problem is here:

    command="head -$temp $fileName | tail -$interval > $tmpFileName"
    

    and later:

    `$command`    
    

    Instead of storing whole piped command in a string you can directly execute the command:

    head -$temp "$fileName" | tail -$interval > "$tmpFileName"
    

提交回复
热议问题