Register
It is currently Sun Sep 21, 2014 4:05 am

how to control output style?


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Mon Aug 24, 2009 3:32 am   

Joined: Mon Aug 24, 2009 3:21 am
Posts: 3
hi,everyone,for example,I have three paragraphs,as following:

aaaaaaa
aaaaaaa
aaaaaaa

bbbbbbb
bbbbbbb
bbbbbbb

ccccccc
ccccccc
ccccccc

I want to output it as following:

aaaaaaa | bbbbbbb | ccccccc
aaaaaaa | bbbbbbb | ccccccc
aaaaaaa | bbbbbbb | ccccccc

how can do it?thanks very much.


Top
 Profile  
 PostPosted: Mon Aug 24, 2009 11:10 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 548
Code:
cat holmes86.-20080824.dat
aaaaaaa1
aaaaaaa2
aaaaaaa3

bbbbbbb1
bbbbbbb2
bbbbbbb3

ccccccc1
ccccccc2
ccccccc3


Code:
#!/bin/bash

n=1
while read line
do
   [[ $line =~ ^$ ]] && {
      echo $line > /dev/null
      ((n++))
   } || {
      echo $line >> holmes-$n
   }
done < holmes86-20090824.dat

exec 3<holmes-1
exec 4<holmes-2
exec 5<holmes-3

rm holmes-[0-9]

while true
do
   read -u 3 par1
   read -u 4 par2
   read -u 5 par3
   test -z "$par1" -o -z "$par2" -o -z "$par3" && break
   echo "$par1 $par2 $par3"
done

aaaaaaa1 bbbbbbb1 ccccccc1
aaaaaaa2 bbbbbbb2 ccccccc2
aaaaaaa3 bbbbbbb3 ccccccc3


Last edited by Watael on Wed Aug 26, 2009 2:56 am, edited 1 time in total.

Top
 Profile  
 PostPosted: Mon Aug 24, 2009 10:26 pm   

Joined: Mon Aug 24, 2009 3:21 am
Posts: 3
Watael,thank you very much!


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP