所以我想根据第 8 列将一个相当大的文件分成几个小文件。所以我写了这个脚本:
#!/bin/bash
run_command(){
eval ${1}
wait
}
chInput=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "Z" "T" "G" "F" "A" "D" "P")
sampInput=("heyA")
for ((x=0;x<${#chInput[@]};x++));do
com="awk -F'\t' '$8=="${chInput[x]}"' /home/location/"$sampInput"_This_P.txt > "$sampInput"Ch"${chInput[x]}".txt"
run_command "${com}"
done
但它不起作用,因为
'$8=="
awk: ==1
awk: ^ syntax error
awk: ==2
awk: ^ syntax error
awk: ==3
awk: ^ syntax error
awk: ==4
awk: ^ syntax error
但只是做
awk -F'\t' '$8==1' /home/location/heyA_This_P.txt > Ch1.txt
从命令行确实有效
我能做些什么来解决这个问题?