Replace with last date update


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Replace with last date update
# 1  
Old 09-25-2014
If you want to keep the sort, but get rid of the syntax errors in your date command and the last awk command, and produce output similar to what you said you want; you could try something like:
Code:
sort -rn file | awk 'BEGIN { FS = OFS = "|"} NR == 1 { d = $1 } { $1 = d } 1'

but Akshay's approach is much more efficient and produces the output you said you wanted.

Last edited by Don Cragun; 09-25-2014 at 07:32 AM.. Reason: There was also an unknown option in your 2nd awk.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies

2. UNIX for Beginners Questions & Answers

How to replace a parameter(variable) date value inside a text files daily with current date?

Hello All, we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies

3. UNIX for Beginners Questions & Answers

“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ Code: line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies

4. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies

5. Shell Programming and Scripting

[Solved] Replace yesterday date with today's date except from the first line

Hello, I have a file like this: 2012112920121130 12345620121130msABowwiqiq 34477420121129amABamauee e7748420121130ehABeheheei in case the content of the file has the date of yesterday within the lines containing pattern AB this should be replaced by the current date. But if I use... (3 Replies)
Discussion started by: Lilu_CK
3 Replies

6. Shell Programming and Scripting

Replace date on a line with current date

Hi Guys, I have a file with following content From 20121014 : To 20121014 Number of days : 1 1234 1245 1246 1111 Everyday i run my script i want to modify "To" date on the first line with current date. I have set the current date in script as RUN_DATE=`date -u +%Y%m%d` So i want... (9 Replies)
Discussion started by: jakSun8
9 Replies

7. Shell Programming and Scripting

Searching for unknown date inside the file and replace to new date

Hello, Iam a newbies to Shell scripting. Iam trying to replace the date inside the file to new date. is there anyway that we can just use the pattern to search as "..." I have many files want to replace with the same date, and each file contains different date. Thanks for your help. ... (2 Replies)
Discussion started by: Daro
2 Replies

8. Shell Programming and Scripting

how to update date part with new increment date time

hi experts, my requirement is like this i need to develop a shell script to update date part with new incremental date time in file some 'X' which is kept at some server location incrementing every two hours.as i am new to this scripting i need support from u people,thanx in advance (1 Reply)
Discussion started by: amanmro
1 Replies

9. Shell Programming and Scripting

Search Replace and Update a file

hi, I am stuck at a place. Please help me out. Here is what i need to do. Search for a pattern in a propertyfile and change only at one occurance. I have these statements and assignment as a part of the propertyfile #Note : The Address should be replaced with actual address dynamically. ... (7 Replies)
Discussion started by: raghu_shekar
7 Replies

10. Shell Programming and Scripting

replace old date in scripts with new date

Hiee .... i want an immediate solution for this.... Let replace.cfg file contains a list of files to be replaced the old dates with new dates...... The script must take 3 parameters.... 1) old date 2) new date 3) .config file Can u get me the solution...... I tried with sed but i... (2 Replies)
Discussion started by: prasanna1983
2 Replies
Login or Register to Ask a Question
X_INIT(1gmt)						       Generic Mapping Tools						      X_INIT(1gmt)

NAME
x_init - Initialization of Cross-Over Data Bases. SYNOPSIS
x_init -I DESCRIPTION
The purpose of x_init is to create two key files that will be holding all the cross-over information for all the cruises tested. These files are called xx_base.b and xx_legs.b, and they will contain data for each cross-over and totals for each leg, respectively. x_init will create these two files in the current directory, and write out the fileheader with a 1 as the next record number in the case of xx_base.b. NB! Any previous files with the same names in the current directory will be erased, so use with caution. -I Must be present form initialization to take effect. BEWARE
Both files are binary and have fixed record lengths. The formats of the files are as follows: xx_base.b: Record length = 40 bytes. Rec # 1: fileheader Rec # 2: pairheader Next n recs: crossover-structure Rec # n+3: pairheader etc. The fileheader is a 40 byte character string where the last 10 bytes contains the record number of the last record in the file. The pairheader is a 40 byte character string which contains the names of the two legs in question and the number of COEs generated between them. The crossover-structure contains all the information for one COE, that is lat, lon, time along leg values of gravity, magnetics, and bathymetry at the cross-over point, the heading of track #1, and the heading of track #2. See program listing for more details on formats. The file is sequential in that new data are appended at the end of the file. xx_legs.b: Record length = 204 bytes. Each record contains the complete information for each leg that has been checked. The leg-structure contains fields like year of cruise, number of internal/external COEs for gravity, magnetics, and bathymetry, their means and standard deviations, and the best fitting regression lines, i.e. the dc-shifts and drift-rates computed from the time/error data points. See program listing for com- plete description of record format. SEE ALSO
GMT(1), x_system(1) REFERENCES
Wessel, P. XOVER: A Cross-over Error Detector for Track Data, Computers & Geosciences, 15, 333-346. GMT 4.5.7 15 Jul 2011 X_INIT(1gmt)