Nice solution, frans, but note that your read will strip leading and trailing whitespace, as well as discard backslashes and possibly merge lines. To preserve lines as they appear in the original file, you'd want to use:
while IFS= read -r L
---------- Post updated at 07:15 AM ---------- Previous update was at 07:11 AM ----------
A posix sh approach without arithmetic:
set x y z w
while IFS= read -r line; do
echo "$line" >> $1
set $@ $1
shift
done < A
Thanks for the response and your help.
Just one small change in my query, I would like to automate this like, I would like to specify the number of out put files through commond promt and I have tried the same but it did not work. it would be great if some one help me to make it work. Thanks in advance.
> set_script.sh 3 inputfile
#!/usr/bin/ksh
nof=$1
file=$2
for ((i=1; i<=nof; i++))
do
sed -n -e '$i~4w $x[i]' $file
done