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
copy lines from opne file to another HIMANI UNIX for Dummies Questions & Answers 2 03-15-2008 05:57 AM
retrieved multiple lines on multiple places in a file dala Shell Programming and Scripting 8 03-14-2008 03:28 PM
copy value to multiple lines rko Shell Programming and Scripting 4 12-13-2007 10:56 PM
Copy only the initial 10 lines from a file to another jockey007 Shell Programming and Scripting 5 11-02-2007 02:05 PM
Copy a file to multiple hosts sumsriva UNIX for Advanced & Expert Users 5 09-18-2007 04:42 AM

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 01-08-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
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
  #2 (permalink)  
Old 01-08-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 753
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

  #3 (permalink)  
Old 01-08-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
Thanku so much its working perfectly !!
  #4 (permalink)  
Old 01-08-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
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?
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:07 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