Sponsored Content
Full Discussion: Remove when date is higher
Top Forums UNIX for Dummies Questions & Answers Remove when date is higher Post 302924027 by radius on Thursday 6th of November 2014 12:04:28 AM
Old 11-06-2014
Remove when date is higher

Dear Masters,

I need to eliminate lines from file input 2 when the date in column 1 more than date in column 1 in file input 1

input 1

Code:
20141101|USA|CANSEL|496420000
20141101|USA|CANUT|1069740000
20141101|USA|CANTENG|625920000
20141102|USA|CANUT|413180000
20141103|USA|CANSEL|1364245000
20141103|USA|CANSEL|336455000
20141103|USA|CANSEL|159070000
20141104|USA|CANSEL|1257290000
20141104|USA|CANUT|992000000
20141105|USA|CANUT|909955000

input 2

Code:
20141001|USA|CANSEL|496420000
20141001|USA|CANUT|1069740000
20141001|USA|CANTENG|625920000
20141002|USA|CANUT|413180000
20141003|USA|CANSEL|1364245000
20141004|USA|CANSEL|336455000
20141005|USA|CANSEL|159070000
20141010|USA|CANSEL|1257290000
20141020|USA|CANUT|992000000
20141028|USA|CANUT|909955000

Since the highest date in column 1 is 20141105 ~ (05) then I need to remove lines in column 2 when the date is higher than 05, so my output should like

Code:
20141001|USA|CANSEL|496420000
20141001|USA|CANUT|1069740000
20141001|USA|CANTENG|625920000
20141002|USA|CANUT|413180000
20141003|USA|CANSEL|1364245000
20141004|USA|CANSEL|336455000
20141005|USA|CANSEL|159070000

this lines will be excluded since the date is 10,20,28
Code:
20141010|USA|CANSEL|1257290000
20141020|USA|CANUT|992000000
20141028|USA|CANUT|909955000

thanks

Last edited by radius; 11-06-2014 at 01:43 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to remove files with a date

I have files with a date name ( 20060506 20060507 etc..) that i want to remove because it keeps filling up the directory. Can someone please help me with a script to remove those date files. i would like to keep atleast 14 days worth from the current date. I hope i have explained it clearly and... (5 Replies)
Discussion started by: justintime
5 Replies

2. Shell Programming and Scripting

Remove out date logs

hi all, i would like to write the shell script to remove the out-dated log my log file name will be like this: access_20050101.log access_20050102.log . . . access_20071007.log access_20071008.log access_20071009.log i has try to write the command as following, it will be remove the... (2 Replies)
Discussion started by: eric_wong_ch
2 Replies

3. UNIX for Dummies Questions & Answers

Remove the date from the file

Hi I am getting the file which is having the format as follows: set-I abcxyz20080109 abc20080110 Set-II abc-20070109 abcxyz-20070110 I need to get only the file name without date as Set-I abcxyz abc Set-II abc (5 Replies)
Discussion started by: pradkumar
5 Replies

4. Solaris

Remove logs by date

Hi I Need To Remove Logs Older Than April 1 St(4/1/2007) By Date I Have A Script To Remove 3 Months Old Like Using 90 Days Thanks (3 Replies)
Discussion started by: cvdev
3 Replies

5. UNIX for Dummies Questions & Answers

To remove files before certain date

I juz started to pick up unix nott long. What i am gonna do here is to try and remove some files before a date. (example 1st Oct 2008) Format of files name: fileA_2008MMDD I did a ls -lrt to list all the files Followed by rm 200801** .. .. ..... (4 Replies)
Discussion started by: Attitude
4 Replies

6. UNIX for Dummies Questions & Answers

grep 2000 and higher

i have content that looks like this: 0003326050 A E LITHO 0023823422 AMERICAN RED CROSS 0005713642 ARUP LABORATORIES 0003206450 CAEL 0002519930 CARDINAL HEALTH 0002619063 FISHER HEALTHCAR 0065203177 OWENS & MINOR INC 0016552938 STAPLES INC 0000002001 MSC... (8 Replies)
Discussion started by: tjmannonline
8 Replies

7. Shell Programming and Scripting

Checking for higher usage and mark it

Hi Gurus, I'm using HPUX B.11.23 U ia64 with sh shell. Is it possible to insert a word "Warning" in the end of this line if there is high percentage? For example: if the percentage is higher than 80%? Sample data: /dev/vgsap/TEST1 /oracle/TST/TEST1 9.89 GB 8.37 GB ... (11 Replies)
Discussion started by: superHonda123
11 Replies

8. UNIX for Beginners Questions & Answers

Compare date in .txt with system date and remove if it's lesser than system date

Can someone help me with the code wherein there is a file f1.txt with different column and 34 column have expiry date and I need to get that and compare with system date and if expiry date is <system date remove those rows and other rows should be moved to new file f2.txt . I don't want to delete... (2 Replies)
Discussion started by: Stuti
2 Replies

9. Answers to Frequently Asked Questions

Compare date in .txt with system date and remove if it's lesser than system date

I m working on shell scripting and I m stuck where in my .txt file there is column as expiry date and I need to compare that date with system date and need to remove all the rows where expiry date is less than system date and create a new .txt with update. (1 Reply)
Discussion started by: Stuti
1 Replies
PR(1)							      General Commands Manual							     PR(1)

NAME
pr - print file SYNOPSIS
pr [ option ] ... [ file ] ... DESCRIPTION
Pr produces a printed listing of one or more files. The output is separated into pages headed by a date, the name of the file or a speci- fied header, and the page number. If there are no file arguments, pr prints its standard input. Options apply to all following files but may be reset between files: -n Produce n-column output. +n Begin printing with page n. -h Take the next argument as a page header. -wn For purposes of multi-column output, take the width of the page to be n characters instead of the default 72. -ln Take the length of the page to be n lines instead of the default 66. -t Do not print the 5-line header or the 5-line trailer normally supplied for each page. -sc Separate columns by the single character c instead of by the appropriate amount of white space. A missing c is taken to be a tab. -m Print all files simultaneously, each in one column, Inter-terminal messages via write(1) are forbidden during a pr. FILES
/dev/tty? to suspend messages. SEE ALSO
cat(1) DIAGNOSTICS
There are no diagnostics when pr is printing on a terminal. PR(1)
All times are GMT -4. The time now is 03:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy