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
shell script to find and replace string in multiple files pharos467 Shell Programming and Scripting 11 01-15-2009 11:40 AM
perl-like split function for bash? eur0dad Shell Programming and Scripting 5 09-05-2008 06:23 PM
[KSH] Split string into array piooooter Shell Programming and Scripting 3 09-01-2007 12:22 PM
split string help senthilk615 Shell Programming and Scripting 4 03-27-2006 06:43 PM
split a string gazingdown Shell Programming and Scripting 3 02-09-2006 05:34 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 10-29-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
Quote:
Originally Posted by vikas027 View Post
hey,
This didnt made any file, not even a blank one.
Thanks.
Sorry 'bout that - some awk's increment pre-increment ops don't seem to work the way they supposed to.
Code:
awk '/SERVER/{if (n++) close(output); output= f n} n {print >> output }' f=/vikas/list /vikas/final
On Solaris - use 'nawk' or '/usr/xpg4/bin/awk'
  #9 (permalink)  
Old 10-29-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,793
Code:
nawk '/^SERVER/ { 
	close(f); f = "/vikas/list" ++c 
	} 
{ 
	print > f 
}' /vikas/final
  #10 (permalink)  
Old 10-31-2007
vikas027 vikas027 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 77
Quote:
Originally Posted by vgersh99 View Post
Sorry 'bout that - some awk's increment pre-increment ops don't seem to work the way they supposed to.
Code:
awk '/SERVER/{if (n++) close(output); output= f n} n {print >> output }' f=/vikas/list /vikas/final
On Solaris - use 'nawk' or '/usr/xpg4/bin/awk'

hello friend,

this command is only making two files list1 & list2.

Thanks.
  #11 (permalink)  
Old 10-31-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
works fine with 3 (and more) 'SERVER' lines...
  #12 (permalink)  
Old 11-01-2007
vikas027 vikas027 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 77
Smile Hi All

Hi,

I tried lots of commands including the above ones. They all run fine on Linux machines
BUT not on the solaris machines, dont know the reason behind it.

Anyways, MANY MANY THANKS to all for your time and help. I found this command to work perfectly.

Code:
/usr/xpg4/bin/awk '/SERVER/{n++}{print > f n}' f=/vikas/list /vikas/final
Thanks again.
  #13 (permalink)  
Old 11-01-2007
dummy_needhelp dummy_needhelp is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 23
Can anyone pleasee explain me how the command is interpreted. Thanks alot in advance
Sponsored Links
Closed Thread

Bookmarks

Tags
linux, linux commands

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 05:39 AM.


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