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
command for selecting specific lines from a script gardasgangadhar UNIX for Dummies Questions & Answers 1 05-13-2008 05:29 AM
shell script to search content of file with timestamps in the directory psychobeauty Shell Programming and Scripting 10 04-21-2008 05:37 AM
Retreive content between specific lines ina file chennaitomcruis Shell Programming and Scripting 4 04-19-2008 10:18 AM
Help with selecting specific lines in a large file tansha UNIX for Dummies Questions & Answers 2 02-06-2008 08:26 AM
shell script to edit the content of a file tiger99 Shell Programming and Scripting 3 01-31-2008 04:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-08-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
Urgent: selecting unique specific content of a file using shell script

Hi,

I have a file whose content and format at places is as given below.

print
coloumn ....
coloumn ....
coloumn ....
skip 1 line

print
coloumn ...
skip 1 line


I need to select the following :
print
coloumn ....
coloumn ....
coloumn ....
skip 1 line

and write it into a new file.
And the next
print
coloumn ...
skip 1 line
should be again written to another new file.Both by using shell script.

Thanks in advance
JS
  #2 (permalink)  
Old 01-08-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 558
Code:
num=1
while read line
        do
        [[ "$line" != "END" ]] && { echo "$line">>file_number.$num; }|| { echo "END">>file_number.$num; (( num = num + 1 )); }
        done<file
  #3 (permalink)  
Old 01-08-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
With Awk:

Code:
awk '{close(FILENAME"_"f-1);print>(FILENAME"_"($1=="print"?++f:f))}' data
Use nawk or /usr/xpg4/bin/awk on Solaris.
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 07:52 PM.


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