I want to read this input file and make separate output files with the header as numric value like "111" and the rest of alphabetic data following it. similarly, i want to have 3 other files with numeric header (like 222, 333, 444) and rest of data following them.
I have created the following script but its not helping..
#!/usr/bin/ksh
set -x
linecount=`cat testfile|wc -l`
numval=`cat testfile|grep ^[0-9]|wc -l`
i=0
set -A arr `awk '/[0-9]/{print NR}' testfile`
while [ $linecount -gt 0 ]
do
while [ $i -le $numval ]
do
val=`echo ${arr}`
cat testfile|head -${val} > file${i}
i=`expr $i + 1`
done
linecount=`expr $linecount - 1`
done
Awk try to find the line having number , if it finds assign it to "of" , so all the lines till the next number will stored in a file created as value of "of". Make sure the first line in the input file is a number , otherwise it will create a file name as "of" and stores all the lines till the occurrence of a number.