Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Shell : copying from one file to another file

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-18-2013
giridhar276 giridhar276 is offline
Registered User
 
Join Date: May 2011
Last Activity: 27 November 2016, 7:12 PM EST
Posts: 76
Thanks: 21
Thanked 0 Times in 0 Posts
Shell : copying from one file to another file


Code:
vat.log
--------
null
null statistics
null
 

null
null
Storage Response Time
disk space1
disk space2

I have a log as mentioned above in which I need to copy only the below content to another file using shell scripting. In between null statistics and final null it also includes blank line as well..



Code:
null statistics
null
 

null
null


Could anyone please help me in this regard?

Thanks in advance...
Sponsored Links
    #2  
Old Unix and Linux 01-18-2013
Scott's Unix or Linux Image
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 24 November 2016, 3:05 AM EST
Location: Zürich
Posts: 8,598
Thanks: 343
Thanked 1,093 Times in 949 Posts

Code:
$ awk 'p&&$1&&$1!="null"{p=0}; /null statistics/ {p=1}p' file
null statistics
null
 

null
null

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Copying Information from One File to Another File in Shell tamachan414 Shell Programming and Scripting 1 07-13-2011 05:27 PM
Help with searching for a file in a directory and copying the contents of that file in a new file zel2zel UNIX for Dummies Questions & Answers 6 03-05-2011 01:44 PM
sed command for copying the contents of other file replacing it another file on specifc pattern balrajg Shell Programming and Scripting 0 01-26-2011 10:42 PM
Strange difference in file size when copying LARGE file.. 0ktalmagik Filesystems, Disks and Memory 1 06-03-2006 08:34 PM
copying the csv file into different worksheets of xls file nimish Shell Programming and Scripting 0 10-04-2005 12:30 AM



All times are GMT -4. The time now is 12:38 AM.