for file in *.csv
do
split -n 5 -d -a 1 "$file" "$file"
for each in $(seq -w 2 3)
do
echo $each
filestem="$file$each"
len_filestem=${#filestem}
subs=substr(len_filestem,3,4)
echo $subs
echo $filestem
#awk '{filename = "wrd." int((NR-1)/10000) ".txt"; print >> filename}' $file--$each
awk -v filestem= "{$filestem}" '{filename = substr(filestem,3,5}; print >> filename}' $filestem
done
done
我试图找到字符串的子字符串,但我的脚本在 substr(len_filestem,3,4) 中失败
答案1
错误是后面的空格=
:
-v filestem= "{$filestem}"