Google Answers Logo
View Question
 
Q: need unix script ( No Answer,   2 Comments )
Question  
Subject: need unix script
Category: Computers > Algorithms
Asked by: questioner1234-ga
List Price: $10.00
Posted: 04 Nov 2004 18:00 PST
Expires: 05 Nov 2004 13:59 PST
Question ID: 424631
I need a UNIX script. Right now I do this:

grep VARIABLE access_log > NEWFILE
vi NEWFILE
in vi I use this command :1,$s/VARIABLE //g
then I save the NEWFILE
and I
gzip NEWFILE

I want this done automatically. So a script like this:
>SCRIPT VARIABLE

that will output a NEWFILE with the filename in this format

www.DATE.TIME.VARIABLE

Request for Question Clarification by maniac-ga on 05 Nov 2004 13:35 PST
Hello Questioner1234,

The two line script suggested by Padmapani will work assuming you make
it executable. If that is adequate, I suggest you close the question.
If you need something more, please explain what is needed beyond the
solution already provided.

[I can suggest some minor changes based on my experience if necessary]

  --Maniac
Answer  
There is no answer at this time.

Comments  
Subject: Re: need unix script
From: padmapani-ga on 05 Nov 2004 08:01 PST
 
Its can be done in one line as :

grep VARIABLE snmpd.log | sed 's/VARIABLE//g' | gzip  > newfile.gzip

It can be wrapped in your fave shel/Perl/etc..
Subject: Re: need unix script
From: padmapani-ga on 05 Nov 2004 12:55 PST
 
One caveat though.If you are using a shell script you need to enclose
sed arguments in double quotes to evaluate the argument variable.Here
is the actual script that is wrapper on the script.

------------------------
#/usr/bin/sh
grep $1 access_log | sed "s/$1//g"|gzip  > new.gz
-----------------------

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy