Sponsored Content
Top Forums Shell Programming and Scripting Script to delete old entries from a file Post 302757755 by anil510 on Friday 18th of January 2013 02:14:34 AM
Old 01-18-2013
Script to delete old entries from a file

I need to remove the file entries that are 30 days old. I have a file with the below data.
Code:
111.XX.XX.99 - - [13/Oct/2012:22:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [04/Nov/2012:22:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [01/Dec/2012:22:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [01/Dec/2012:22:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [16/Dec/2012:22:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [17/Dec/2012:22:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [22/Dec/2012:22:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [17/Jan/2013:23:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [17/Jan/2013:22:27:35 -0400] "GET /folder1/wp-content" 304

After applying the script to the file, the output should be as follows.

Code:
111.XX.XX.99 - - [17/Dec/2012:22:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [22/Dec/2012:22:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [17/Jan/2013:23:27:35 -0400] "GET /folder1/wp-content" 304
111.XX.XX.99 - - [17/Jan/2013:22:27:35 -0400] "GET /folder1/wp-content" 304

The lines which is old more than 30 days should be removed from the output.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to Delete all lines in a file from a script

I am trying to delete all the lines out a file from a unix script. Please help Platform is Sun (3 Replies)
Discussion started by: alnita
3 Replies

2. UNIX for Dummies Questions & Answers

find and delete reccuring entries in a file

I have a file with multiple lines, lets say for example magazine1 magazine2 magazine3 magazine3 magazine4 magazine5 So i am trying to find a way to find and delete the duplicate entries. Any ideas? Thanks (3 Replies)
Discussion started by: greekozz
3 Replies

3. Shell Programming and Scripting

Need Script to delete multiple entries from a file

I am new to Linux and would appreciate some help. I need a script to do the following: My file contains the following entries more file 1 1 1 1 2 2 2 I want to delete multiple entries of 1 and 2 and just keep one of each. The output should look like more file 1 2 Thanks (1 Reply)
Discussion started by: sidewayz
1 Replies

4. Shell Programming and Scripting

Delete content of file 1 in file 2 with shell script

OK, best is I explain what the operating enviroment is. Linux, but Motomagx. It is a Linux operated mobile phone, Motorola V8. I am writting a shell script, but got stuck. I have to delete the complete content of file 1 in file 2. I have attached the 2 files. You can see that the content of... (2 Replies)
Discussion started by: rasputin007
2 Replies

5. Shell Programming and Scripting

Logout script - delete a file

Good evening you scripting guru's! I have the following script to delete a file on logout of a Mac : find . –name com.apple.sidebarlists.plist –exec rm -f {} \; It works fine in terminal and when logging out. However, it takes forever to run the script at logout...A minute and a half. ... (12 Replies)
Discussion started by: AGGreenLinux
12 Replies

6. Shell Programming and Scripting

Script that delete a File when a DEL File will be placed in same folder

Hi there, i have a question. I have a folder called /usr/test There is a file in it.... test.csv I need not a shell script that checks if there is a file called: test.del And if the file is in the same folder then the script should delete the test.csv and also the test.del. Hope... (9 Replies)
Discussion started by: Bjoern28
9 Replies

7. Shell Programming and Scripting

Delete old date entries from a file

Hello, I have following log file. alog.log Oct 8 xxxxx Oct 9 xxxxx Oct 10 xxxxx Nov 8 xxxxx Nov 8 xxxxx . . . Jan 8 xxxxx I need to delete all the lines which are having date entries older than 60 days. So If the current date is Jan 9 2011 then it should delete all the lines upto... (3 Replies)
Discussion started by: Ravin83
3 Replies

8. Red Hat

Need Script to ZIP/SAVE & then DELETE Log file & DELETE ZIPS older than 12 months

ENVIROMENT Linux: Fedora Core release 1 (Yarrow) iPlanet: iPlanet-WebServer-Enterprise/6.0SP1 Log Path: /usr/iplanet/servers/https-company/logs I have iPlanet log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I... (7 Replies)
Discussion started by: zachs
7 Replies

9. Shell Programming and Scripting

How to delete the lines from file using script?

Hi Iam having file like below 10.238.52.65 pun-ras-bng-mhs-01 server 10.238.52.65 pun-ras-bng-mhs-01 10.10.10.10 10.238.52.65 pun-ras-bng-mhs-01 10.10.20.10 10.238.54.1 enk-ras-bng-cse-01 server 10.238.54.1 enk-ras-bng-cse-01 10.10.30.10 10.238.54.1 enk-ras-bng-cse-01 10.10.10.10 ... (5 Replies)
Discussion started by: surender reddy
5 Replies

10. Shell Programming and Scripting

Help with UNIX script --Read from one file and delete entries in other

Hi Guru's The script has to read an entry from one file and delete the set of lines form other file. Below is the format of the file. In the below example, script should read the entries from input file 2 and delete the entries from input file 1. Input file 1 cn: test@test1.com abc:... (7 Replies)
Discussion started by: Samingla
7 Replies
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 11:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy