The UNIX and Linux Forums  

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
How to edit a txt file ? RRVARMA Shell Programming and Scripting 4 05-30-2008 09:40 AM
edit a file using ksh meghana Shell Programming and Scripting 3 04-16-2008 12:04 PM
Edit value in File sewood Shell Programming and Scripting 1 03-18-2008 02:11 AM
How to edit env file duke0001 UNIX for Advanced & Expert Users 3 02-16-2007 11:43 AM
Edit an ISO / dd file? WIntellect Filesystems, Disks and Memory 4 11-20-2002 05:21 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-09-2006
sentak sentak is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 13
file edit help

Hi,

Could anyone give me a idea how to strip the lines from a given file. example

***********
1st occurence
1st occurence
1st occurence
1st occurence
***********
2nd occurence
2nd occurence
2nd occurence
2nd occurence
2nd occurence
2nd occurence
*************
3rd occurence
3rd occurence
3rd occurence
3rd occurence
*************

I want to strip the lines between last occurencei:e 3rd occurence to a new file.

rgds
ss
  #2 (permalink)  
Old 11-09-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
something to start with.

Code:
nawk -v RS='*' '$0 != "" {a[++fnr]=$0} END {printf("%s", a[fnr-1])}' myFile.txt
  #3 (permalink)  
Old 11-09-2006
sentak sentak is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 13
Thanks for the response. But I tried on my file and I am getting the below error

nawk: input record ` Disconnected from O...' too long
  #4 (permalink)  
Old 11-09-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
if you have 'gawk' on your system, try it instead of 'nawk'
  #5 (permalink)  
Old 11-10-2006
sentak sentak is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 13
I don't have gawk on my system. I am using sun OS.

But I am tring the below, which is not working either

awk '{
if( $1 == "**********************************" )
{
n=split($2,arr,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
file=arr[n-1] ".txt"
}
print file }' $HOME/tmp/xxxxx.log
  #6 (permalink)  
Old 11-10-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Can you show the input file?
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 06:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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