The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > UNIX Desktop for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX Desktop for Dummies Questions & Answers Questions regarding GNOME, KDE, CDE, Open Office, etc go here. All UNIX and Linux Newbies Welcome !!


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Transposing string unibboy Shell Programming and Scripting 3 02-13-2008 02:12 PM
Major Awk problems (Searching, If statements, transposing etc.) Blivo Shell Programming and Scripting 2 09-05-2007 03:41 AM
Another transposing issue stevesmith Shell Programming and Scripting 14 09-16-2006 01:48 AM
file transposing mskcc Shell Programming and Scripting 24 08-04-2005 08:23 AM
transposing letters myscsa2004 Shell Programming and Scripting 4 05-12-2004 07:11 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-11-2008
Registered User
 

Join Date: Apr 2008
Posts: 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
More than transposing!

Hi everyone,

I have a poblem like that:

I have a file which includes data looks like:

0.65214 0.3597 1.0
0.65244 0.3502 1.0
0.65273 0.3553 1.0
0.65305 0.3544 1.0
0.65327 0.3505 1.0
0.65359 0.3516 1.0
0.65578 0.6464 1.0
0.65605 0.6453 1.0
0.65633 0.6437 1.0
0.65660 0.6488 1.0
0.65688 0.6435 1.0
0.65716 0.6432 1.0
...
...
I have to convert this data to:

0.65214 0.35971.00.65244 0.35021.00.65273 0.35531.00.65305 0.35441.00.65327 0.35051.0
0.65359 0.35161.00.65578 0.64641.00.65605 0.64531.00.65633 0.64371.00.65660 0.64881.0
...
...

Yes, there is no "space" between some values. As you see, five row must convert to one row in given format.

I tried very much, but I could not get it.

Any suggestions?

Regards,
B.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-11-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,228
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Code:
awk ' { printf("%s", $0)
          if(NR%5 == 0) {printf("\n")}
      ' oldfile > newfile
Reply With Quote
  #3 (permalink)  
Old 04-11-2008
Registered User
 

Join Date: Apr 2008
Posts: 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Thanks.

It's very fast.

But it gives the error:

Code:
bulash@linux-sb6k:~/phoebe_data/TZ_Eri> awk ' { printf("%s", $0)
> if(NR%5 == 0) {printf("\n")}
> ' B.txt > A.dat

awk: cmd. line:3: if(NR%5 == 0) {printf("\n")}
awk: cmd. line:3:                             ^ unexpected newline or end of string
Is it normal?

Best wishes,
B.

Last edited by bulash : 04-11-2008 at 01:43 PM.
Reply With Quote
  #4 (permalink)  
Old 04-11-2008
Registered User
 

Join Date: Apr 2008
Posts: 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
OK it works very well...

Thanks indeed again.

B.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 09:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102