I need to split a file and rename it accordingly using awk command. I'm trying to use the substring command and pass a parameter to awk command but it fails.
for file in *.csv
do
split -n 3 -d -a 2 "$file" "$file--"
for each in $(seq -w 2 10)
do
echo $file--$each
awk -v filestem= ${$file--$each:2:5} '{filename = filestem; print >> filename}' $file--$each
done
done