The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
New to scripting, Need help newbie22102 Shell Programming and Scripting 2 02-25-2008 11:08 AM
scripting help james94538 Shell Programming and Scripting 2 02-08-2008 07:36 PM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 08:12 AM
scripting guru's pls help me with scripting on AIX thatiprashant Shell Programming and Scripting 1 01-20-2006 07:58 PM
KSH Scripting dstaller Shell Programming and Scripting 1 11-16-2005 02:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #8 (permalink)  
Old 10-10-2008
treesloth treesloth is offline
Registered User
  
 

Join Date: Oct 2008
Location: Orem, Utah
Posts: 72
Quote:
Originally Posted by avronius View Post
And now, my made up space language
Code:
snurdo <inputfile> {zort blip -f[] $1} | glop | ('{prattle ???}',"Take me to your leader")
Disclaimer: The preceding message was an attempt at humour
Hmmm... is there a compiler for that in /ports?
  #9 (permalink)  
Old 10-13-2008
pkumar3 pkumar3 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 7
Plz Find OUT the error in following code

cut -f 7,34- -d "," first97col.CSV|awk -F\, '{
if ($2!="") printf$1FS c=0
for(i=2;i<=NF;i++)
printf$i (++c%4?i==NF?RS:FS:RS$1FS) fi;
}'

Last edited by pkumar3; 10-13-2008 at 08:41 AM..
  #10 (permalink)  
Old 10-13-2008
nani123 nani123 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 2
Thanks a lot ........
  #11 (permalink)  
Old 10-13-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
Quote:
Originally Posted by pkumar3 View Post
Hi I have a similar problem.
source file is of format
1,a,b,c,d,e,f,g,h
2
3,f,g,h,i,l
4
5,m,n

And the expected Output file
1,a,b,c
1,d,e,f
1,g,h
3,f,g,h
3,i,l
5,m,n

I used this method
awk -F, '$1!=p1{printf "%s,%s,%s,%s\n",$1,$2,$3,$4} $2!=p2{printf "%s,%s,%s,%s\n",$1,$5,$6,$7,$8; p1=$1;p2=$2}'

the no of coloumns in source file is of varriable length and can grow upto 3000.
Code:
perl -F, -nae'if($#F){s/((?:(?:.*?),){3}[^,]*)/$1\n$F[0]/g;print}' filename
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

BB 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 -4. The time now is 02:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0