Replace with last date update


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Replace with last date update
# 8  
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_OVER(1gmt)						       Generic Mapping Tools						      X_OVER(1gmt)

NAME
x_over - Find and compute Cross-Over Errors SYNOPSIS
x_over leg_1 [ leg_2 ] [ -A ] [ -C ] [ -L ] [ -V ] [ -Wtimegap ] [ -Gfact ] [ -Mfact ] [ -Tfact ] [ -Nnp_int ] DESCRIPTION
x_over is used to inspect two cruises to see if they intersect, and if so report the time, position, discrepancies in gravity/magnetics/ba- thymetry, heading for each track segment, and the average values of the geophysical observables at the cross-over point. The names of the legs are passed on the command line. If they are identical or only one name is passed, then x_over looks for internal cross-overs. The optional parameters are: -A Use an Akima spline to interpolate the geophysical field at the cross-over point. -C Use a Natural Cubic spline function instead. -L Use a linear interpolant [Default]. -W Do not compute cross-overs if the 2 nearest points are more than timegap minutes apart. -G Scale gravity by fact [Default is 0.1 since gmt-files store gravity in g.u.] -M Scale magnetic anomaly by fact [1.0]. -T Scale bathymetry by fact [1.0]. -N Specify how many points to use in the interpolation [Default is 6]. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. Report the number of cross-overs for this pair of legs. BEWARE
The COEs found are printed out to standard output in ASCII format. The first record contains the leg names and their start year, whereas subsequent records have the data for each COE encountered. The fields written out are lat, lon, time along track #1, time along track #2, x_gravity, x_magnetics, x_bathymetry, average gravity, average magnetics, average bathymetry, heading along track #1, and heading along track #2. Sign convention: If lega and legb are passed on the command line, then the COE value is Value (lega) - Value (legb). It is rec- ommended that the Akima spline is used instead of the natural cubic spline, since it is less sensitive to outliers that tend to introduce wild oscillations in the interpolation. 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_OVER(1gmt)