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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
copy lines from opne file to another HIMANI UNIX for Dummies Questions & Answers 2 03-15-2008 02:57 AM
retrieved multiple lines on multiple places in a file dala Shell Programming and Scripting 8 03-14-2008 12:28 PM
copy value to multiple lines rko Shell Programming and Scripting 4 12-13-2007 07:56 PM
Copy only the initial 10 lines from a file to another jockey007 Shell Programming and Scripting 5 11-02-2007 11:05 AM
Copy a file to multiple hosts sumsriva UNIX for Advanced & Expert Users 5 09-18-2007 12:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-07-2008
Registered User
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 138
How to copy multiple lines from a file to another using AWK?

Hi,

I have a abc.txt file.

In this file there is a SQL query which Iwant to copy and print it on another file.The query (for eg) is written like this:

SELECT field1,
field2,
field3
from table1,table2
where <conditions>
END

I want to copy this query to another file using AWK.Its very urgent .Can someone help me in this.

Thanks in advance.
JS
Reply With Quote
Forum Sponsor
  #2  
Old 01-07-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 570
Quote:
Originally Posted by jisha View Post
Hi,

I have a abc.txt file.

In this file there is a SQL query which Iwant to copy and print it on another file.The query (for eg) is written like this:

SELECT field1,
field2,
field3
from table1,table2
where <conditions>
END

I want to copy this query to another file using AWK.Its very urgent .Can someone help me in this.

Thanks in advance.
JS
Code:
awk '/SELECT/,/END/{print}' abc.txt > newfile
Reply With Quote
  #3  
Old 01-07-2008
Registered User
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 138
Thanku so much its working perfectly !!
Reply With Quote
  #4  
Old 01-07-2008
Registered User
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 138
Quote:
Originally Posted by jisha View Post
Thanku so much its working perfectly !!
What If i dont want to print the first and the last line but everthing else?
For eg : I dont want to print the SELECT and Last line, END but have to print all lines in between these two?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:27 AM.


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

Content Relevant URLs by vBSEO 3.2.0