Sponsored Content
Full Discussion: Replace second match+awk/sed
Top Forums Shell Programming and Scripting Replace second match+awk/sed Post 302876377 by klane on Saturday 23rd of November 2013 01:59:11 PM
Old 11-23-2013
RudiC,

Your tac code changes the time on the entry before but it doesn't also change the date.

So for the text it reads:
Code:
sta WP00 34.07335 -106.91932 
time 10/23/2013 20:10:17
sensor trillium_240_2 0 583
add
close sensor trillium_240_2 10/23/2013 20:20:28

sensor trillium_120 0 279
add
close sensor trillium_120 10/23/2013 20:20:28

Instead of having 10/28/2013 20:20:28. It's definitely a faster approach but it's missing the date too. I'm not familiar with tac, how would you add in the date element to it? Also the change to close statement to be 12/31/2500 only changes the very last entry, but I would like it to change the very last entry for each station that it runs through. In the example text there is only one station but in the full text file there are many more. Ideas?

And thanks for the help!
Moderator's Comments:
Mod Comment Please use CODE tags and stop depending on site administrator's to fix your posts for you.

Last edited by Don Cragun; 11-23-2013 at 04:26 PM.. Reason: Add CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed scripting, match text within line and replace

New to sed... Have a file foo.txt (below). Need to replace text on 2 lines, but can only feed sed the first few characters of each line (all lines are unique). So, in my example, I have put '$' in place of what I need to figure out how to feed the whole line. What I have thus far: sed -e... (6 Replies)
Discussion started by: boolean2222
6 Replies

2. Shell Programming and Scripting

SED to replace exact match, not first occurrence.

Lets say I have file.txt: (Product:Price:QuantityAvailable) (: as delimiter) Chocolate:5:5 Banana:33:3 I am doing a edit/update function. I want to change the Quantity Available, so I tried using the SED command to replace 5, but my Price which is also 5 is changed instead. (for the Banana... (13 Replies)
Discussion started by: andylbh
13 Replies

3. Shell Programming and Scripting

Match and replace value in 2 different places using awk

Hi, I need help on replacing values in certain field in my file1.txt based on matched patterns in file2.txt using awk. The blue color need to match with one of the data in field $2 in file2.txt. If match, BEGIN and FINISHED value in red will have a new value from field $3 and $4 accordingly.... (3 Replies)
Discussion started by: redse171
3 Replies

4. Shell Programming and Scripting

Match a Pattern & Replace The value Using AWK

I have a csv file in which i have to search a particular string and replace the data in any column with something else. How do i do it using awk. file ------ 2001,John,USA,MN,20101001,29091.50,M,Active,Y 2002,Mike,USA,NY,20090130,342.00,M,Pending,N... (3 Replies)
Discussion started by: Sheel
3 Replies

5. UNIX for Dummies Questions & Answers

awk/sed match and extraction

Hi, I have a file like this- aa 12 23 34 aa 21 34 56 aa 78 45 56 I want to print out only the lines after the last aa. How do I do this? I tried using grep -A and sed -n, but both didnt work as I wanted to. Could someone help me out please.. (3 Replies)
Discussion started by: jamie_123
3 Replies

6. Shell Programming and Scripting

sed Character match and replace

Hello All I am struck in the issue which I want to share with all of you. What I am trying to do is For every line in a file I have to replace a particular character from the given character in a file For Example Suppose the data is 1111x2222 1111x2222 2222y3333 1111x2222 I... (4 Replies)
Discussion started by: adisky123
4 Replies

7. Shell Programming and Scripting

awk Match First Field and Replace Second Column

Hi Friends, I have looked around the forums and over online but couldn't figure out how to deal with this problem input.txt gene1,axis1/0/1,axis2/0/1 gene1,axis1/1/2,axis2/1/2 gene1,axis1/2/3,axis2/2/3 gene2,axis1/3/4,axis2/3/4 Match on first column and if first column is... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

8. Shell Programming and Scripting

Need help with sed to match and replace a string

friends I am struck in a situation where I need to comment a line start with space as below in a file root@LOCALHOST * rw LOCALHOST* r I should comment second line only Any help please (16 Replies)
Discussion started by: mallak
16 Replies

9. Shell Programming and Scripting

sed : replace Nth match in a file

I have a situation where a file "config.txt" looks like this Servername: OS: Serername: OS: Servername: OS: .... .... ... Servername: OS: looking for the sed syntax to replace the "Nth" occurrence of Servername (i would apply the same logic to OS as well), want to replace the Nth... (4 Replies)
Discussion started by: alldbest
4 Replies

10. Shell Programming and Scripting

Pattern match and replace indirect directory reference using sed

Hi, I need a ksh script to replace indirect directory references in an .ini file with a env variable using sed or awk. The .ini file is for example as such: A=.. B=../ C=../.. D=../../ E=../bin F=../../bin G=../../bin/xml H=../../bin/xml/ Need to replace an instance of .. or... (2 Replies)
Discussion started by: andyatit
2 Replies
SoAlarmSensor(3)						       Coin							  SoAlarmSensor(3)

NAME
SoAlarmSensor - The SoAlarmSensor class is a sensor which will trigger once at a specified time. SoAlarmSensor provides a convenient way of setting up triggers for jobs which should be executed only once when they are scheduled. SYNOPSIS
#include <Inventor/sensors/SoAlarmSensor.h> Inherits SoTimerQueueSensor. Public Member Functions SoAlarmSensor (void) SoAlarmSensor (SoSensorCB *func, void *data) virtual ~SoAlarmSensor (void) void setTime (const SbTime &abstime) void setTimeFromNow (const SbTime &reltime) const SbTime & getTime (void) const virtual void schedule (void) Additional Inherited Members Detailed Description The SoAlarmSensor class is a sensor which will trigger once at a specified time. SoAlarmSensor provides a convenient way of setting up triggers for jobs which should be executed only once when they are scheduled. Constructor &; Destructor Documentation SoAlarmSensor::SoAlarmSensor (void) Default constructor. SoAlarmSensor::SoAlarmSensor (SoSensorCB *func, void *data) Constructor taking as parameters the sensor callback function and the userdata which will be passed the callback. See also: setFunction(), setData() SoAlarmSensor::~SoAlarmSensor (void) [virtual] Destructor. Member Function Documentation void SoAlarmSensor::setTime (const SbTime &abstime) Set the time at which the sensor will trigger. Note that you must manually schedule() the sensor after calling this method. See also: setTimeFromNow(), getTime() void SoAlarmSensor::setTimeFromNow (const SbTime &reltime) Set the alarm to be at a specified offset from the current time. Note that you must manually schedule() the sensor after calling this method. See also: setTime(), getTime() const SbTime & SoAlarmSensor::getTime (void) const Returns the trigger time for the alarm as an absolute value from 1970-01-01 00:00:00. See also: setTime(), setTimeFromNow() void SoAlarmSensor::schedule (void) [virtual] Put the sensor in the global timer queue. See also: unschedule(), isScheduled() Reimplemented from SoTimerQueueSensor. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SoAlarmSensor(3)
All times are GMT -4. The time now is 01:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy