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
copy contents of one column in another raman1605 Shell Programming and Scripting 4 05-12-2008 08:58 AM
Copy selected Directories sigurarm UNIX for Dummies Questions & Answers 2 12-21-2007 12:57 PM
Automatic Copy of File Contents to Clipboard ilak1008 Shell Programming and Scripting 5 10-10-2006 11:43 AM
how to do selected copy dbasan SUN Solaris 3 06-13-2006 11:19 AM
copy folder contents robsk8_99 UNIX for Dummies Questions & Answers 1 02-22-2005 06:54 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 10-05-2006
misenkiser misenkiser is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 36
Copy selected contents from file

I want to capture contents of a file between 2 strings into another file

for eg all lines in between the keywords "start log" and "end log" should be copied into another file
  #2 (permalink)  
Old 10-05-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
Here's a start:
Code:
echo "foo
bar
baz
quux
blorp" | awk '/bar/,/quux/ { print }'
  #3 (permalink)  
Old 10-05-2006
misenkiser misenkiser is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 36
Hi

Will this work from command prompt by just giving input and o/p file names ?
  #4 (permalink)  
Old 10-05-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
Sure...
Code:
awk '/bar/,/quux/ { print }' file1 > file2
  #5 (permalink)  
Old 10-05-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
using sed

Code:
sed "/start log/,/end log/w filenm" orig_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 09:09 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