I have shell script that is calling paste that is not acting as I would
think that it would. When it gets to the paste part it should
interpret the line as paste -d'\0' p[1-40] > new.file
but it only concatenates the first 4 files. it seems that it does not
know how to interpret a 2 digit number. as you can see from the file, i
also tried to put in the numbers themselves (1,2,3,etc.) but it still
left off the 10th file.
It may be something I'm doing wrong, but I thought I would give it a
shot.
Thanks!
The script is as follows:
if [ $# -ne 3 ]; then
echo "Usage: conv <input file> <output file > <delimiter
character>"
exit 1
fi
n=`awk -F${3} ' BEGIN { getline ; print NF } ' ${1}`
echo "n=" ${n}
i=${n}
while [ ${i} -gt 0 ]
do
cut -d${3} -f${i} ${1} > f${i}
# maxlen=`awk '{ if ( length($0) > x ) x = length($0) ;
maxlen=`awk '{ x = length($0);
if ( $0 != "" && $0 != "\t")
print $0,length($0) >"l"'${i}' ;
else print "^ 1" >"l"'${i}' } END { print x }'
f${i}`
while read field len
do
if [ $field = "^" ]; then
field=" "
fi
echo "field=" $field
while [ $len -lt $maxlen ]
do
field="$field"
len=`expr ${len} + 1`
done
echo "$field" >> p${i}
done < l${i}
i=`expr ${i} - 1`
done
echo "n=" ${n}
paste -d'\0' p[1-${n}] > ${2}
# paste -d'\0' p[1,2,3,4,5,6,7,8,9,10] > ${2}
rm f?? f? l?? l? p?? p?
--
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Natalie Knight Red Hat, Inc.
IT Technical Developer 2600 Meridian Pkwy
919.547.0012 ext 331 Durham, NC 27709
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>