1825764 Members
2075 Online
109687 Solutions
New Discussion

Re: scripts

 
Cifs 9000
Advisor

scripts

i have a dat (text ) . Example

abcd:abcd:acbd
cdlcd:cdcdc:cdcd
more than 50 row.

I want to display on screen with numbering and should be fix in one screen. like slit one column into 3 or 2.

I want out put like that

1.abcd:abcd:acbd 2.cdlcd:cdcdc:cdcd
3. 4.

3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: scripts

Which OS is this for, HP-UX?
Arturo Galbiati
Esteemed Contributor

Re: scripts

Hi,
on HP-UX:
cat -n | paste -s -d"\t\n" -

Rgds,
Art

N.B. Please assign points!
Dave La Mar
Honored Contributor

Re: scripts

Down and dirty -
num=0
cat "your_data_file" | while read line
do
let num="$num+1"
expr "$num" % 2 | read mod
if [ $mod != "0" ]
then
echo "$num". "$line \c" >> output_file
else
echo "$num". "$line " >>output_file
fi
done

Change $num % 2 to $num % 3 for 3 columns and so on.

Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."