LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-13-2011, 05:17 AM   #1
Doknik
LQ Newbie
 
Registered: Jun 2010
Posts: 26

Rep: Reputation: 1
Shell Script or Command to Remove PDF file from large logs


Hi,
I need to remove a large binary file(PDF file) from a large log file which is generated daily.This is seriously hogging space on our servers.I need to remove the large PDF from the logs to make the logs smaller and manageable

I need to take out the texts (or binary file) between the strings

<my:PDF> and </my:PDF>


<applicationForm> and </applicationForm>

<image> and </image>

<extractedSignature> and </extractedSignature>


I am not sure whether sed utility can do this, these are large files and need to be pruned .I am not seeking logrotation advice just a script or command that can strip these large logs of texts between the characters above . I am not sure how to do this.These files are rather large.I am not sure how to achieve this with sed , tail, head , tr or any other facility .
Your help would be greatly appreciated.
 
Old 07-13-2011, 05:42 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can try:
Code:
sed '/<applicationForm>/,/<\/applicationForm>/d' file.log
if you are satisfied of the result (sent to standard output) then you can run the command again adding the -i option to actually change the file content. Or use -i.bck to keep a backup copy of the file itself, so that you can easily do a diff between the input and the output file. I would run multiple sed command to remove the different key pairs. Hope this helps.
 
Old 07-14-2011, 08:39 AM   #3
Doknik
LQ Newbie
 
Registered: Jun 2010
Posts: 26

Original Poster
Rep: Reputation: 1
Colucix, Thanks a million i tried this and it works it ruduced the file size drastically..i really appreciate your help.have a good day
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
writting shell script and save in PDF file maryamabd Linux - Newbie 10 04-25-2009 10:34 AM
shell script read line from file, use it in command DiGiGoth Programming 5 08-31-2008 11:08 AM
shell command to remove all .exe file limit_me Linux - Newbie 2 05-29-2007 11:12 PM
Script File: Parsing command sent to shell cheema Programming 1 07-01-2005 12:54 PM
Very large pdf file size gmgartner Linux - Software 5 04-28-2005 11:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration