Sponsored Content
Top Forums Shell Programming and Scripting Grep only specific lines ordered by column/date Post 302558761 by Scott on Sunday 25th of September 2011 07:53:55 AM
Old 09-25-2011
It would be simpler if the date was stored in YYYYMMDD format.

Some of your field numbers were wrong. Field "2", for example, is actually two fields in some cases. It's possible that the actual output is tab-delimited, but you just didn't paste it properly here?

This will add an extra field with that data format, then sorting is easier...

Code:
$ awk '$2=="Backup" && $4 {split( $8, D, "/"); T=$9; gsub( /:/, "", T); print D[3]D[1]D[2]T, $0}' file1 | sort -nk1
110830200000 928458   Backup   Done    196      ADDICTION_TRADEFIN_EXPORT                       Full                     addiction                               08/30/11 20:00:00  08/30/11 22:00:03  002:00:03              1
110906200000 933442   Backup   Done    196      ADDICTION_TRADEFIN_EXPORT                       Full                     addiction                               09/06/11 20:00:00  09/06/11 22:00:03  002:00:03              1
110913200000 938526   Backup   Done    196      ADDICTION_TRADEFIN_EXPORT                       Full                     addiction                               09/13/11 20:00:00  09/13/11 22:00:03  002:00:03              1
110923210000 945927   Backup   Done    196       SQL_SERVER_FALCON_BACKUP                       Full                           BAZ                               09/23/11 21:00:00  09/23/11 23:00:03  002:00:03

The last bit about getting the last two days I leave to you (or anyone else) Smilie.
This User Gave Thanks to Scott For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed replace values of column with ordered numbering

Hello, I am trying to write a shell script that will create a gnuplot file. My main problem is that I have a data file with two columns: 1.05929120E+09 5.0000701214792 1.05930096E+09 5.00006386985764 1.05930584E+09 5.00019465404908 1.05931072E+09 5.00031960589719 ... (2 Replies)
Discussion started by: pau
2 Replies

2. Shell Programming and Scripting

script for get lines with specific date

I'm a newbie in AIX, i want to make a script for grep any lines with date bellow 20 PRINT0089-88615 data1 3072 Mon Dec 19 17:53:49 WITA 2011 PRINT0089-88616 data1 4096 Mon Dec 19 17:53:49 WITA 2011 PRINT0089-88618 data1 5120 Mon Dec 19... (7 Replies)
Discussion started by: michlix
7 Replies

3. Shell Programming and Scripting

Grep all lines for a specific date in log-files

I need to grep all lines for "yesterday" in /var/log/messages. Dates are in the format "YYYY-MM-DD". (5 Replies)
Discussion started by: Padmanabhan
5 Replies

4. Shell Programming and Scripting

Extract lines with unique value using a specific column

Hi there, I need a help with extracting data from tab delimited file which look like this #CHROM POS ID REF ALT Human Cow Dog Mouse Lizard chr2 3033 . G C 0/0 0/0 0/0 1/1 0/0 chr3 35040 . G T 0/0 0/0 ./. 1/1 0/1 chr4 60584 . T G 1/1 1/1 0/1 1/1 0/0 chr10 7147815 . G A 0/0 1/1 0/0 0/0... (9 Replies)
Discussion started by: houkto
9 Replies

5. Shell Programming and Scripting

How to awk or grep the last column in file when date on column contains spaces?

Hi have a large spreadsheet which has 4 columns APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96034 Storage Mgmt Team APM00111803814 server_2 96152 GWP... (6 Replies)
Discussion started by: kieranfoley
6 Replies

6. UNIX for Dummies Questions & Answers

Grep specific lines

Hello I have a file with nearly 90000 lines in x,y,z format but have some lines that I do not need to show. Is there anyway to delete those 3 lines after every 288 lines. Eg I keep the first 288 lines delete (289, 290 291); keep the next 288 lines after those and so on... Thanks (6 Replies)
Discussion started by: Madiouma Ndiaye
6 Replies

7. Shell Programming and Scripting

Grep on a value in a specific column

I need to grep all records from a file that has 1072 in 3rd column. 1072 can be prefixed by "SBC.", "CLS." or "DPT.". My search is just based on string 1072 in 3rd column. Delimiter in the file is tab. For example: Input FIle: "InvType" "Organization" "SBC.10720101" "CP.BUP.NY" "InvType"... (4 Replies)
Discussion started by: yale_work
4 Replies

8. UNIX for Dummies Questions & Answers

Highlighting specific column in cat/grep

I have a large * delimited text file and need to highlight specific columns on specific lines. The file looks similar to this: ABC*01*00*01*00000 000000 *00000 000000 *35*0*0*0*0*20000*0*0*1*0000*00*4*0*3*0*0*1*0* *35*0000*001*4*1OT2*0148*0*0*0*0*0*0*6A7801B0**TEST1... (1 Reply)
Discussion started by: say170
1 Replies

9. Shell Programming and Scripting

Can grep a specific column?

Hello All I have an input file with data below. I would like to grep and display the data where 3rd column contains string or at least one character. Kindly please help me with this! Input: tjfa3|zznpou|224fdd.34.ff3.35 |Tiv|Otj|1 fgduul7|zznikj| ... (7 Replies)
Discussion started by: DoveLu
7 Replies

10. UNIX for Beginners Questions & Answers

Help with Grep Specific Date From One File Into A New One

Hello All, First post, don't know much about Linux/Unix, but I need some help. Normally, I do grep 'what I'm searching for' FILE > file.txt so I can pull data from one file, and put it into a new one. The issue I am having is with specific dates, since the date field is 4, and it appears... (3 Replies)
Discussion started by: DennisG34
3 Replies
BACKUPLOG(5)							AFS File Reference						      BACKUPLOG(5)

NAME
BackupLog - Traces Backup Server operations DESCRIPTION
The BackupLog file records a trace of Backup Server (buserver process) operations on the local machine and describes any error conditions it encounters. If the BackupLog file does not already exist in the /var/log/openafs directory when the Backup Server starts, the server process creates it and writes initial start-up messages to it. If there is an existing file, the Backup Server renames it to BackupLog.old, overwriting the existing BackupLog.old file if it exists. The file is in ASCII format. Administrators listed in the /etc/openafs/server/UserList file can use the bos getlog command to display its contents. Alternatively, log on to the machine and use a text editor or a file display command such as the UNIX cat command. By default, the mode bits on the BackupLog file grant the required "r" (read) permission to all users. The Backup Server records operations only as it completes them, and so cannot recover from failures by reviewing the file. The log contents are useful for administrative evaluation of process failures and other problems. SEE ALSO
UserList(5), bos_getlog(8), buserver(8) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 BACKUPLOG(5)
All times are GMT -4. The time now is 09:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy