Sponsored Content
Top Forums Shell Programming and Scripting Replace date value with another value keeping all as is Post 302510151 by vgersh99 on Friday 1st of April 2011 04:19:24 PM
Old 04-01-2011
Code:
sed "s#'[^'][^']*#'newdate#1" myFile

replace
match pattern: single-quote followed by anything BUT a single-quote repeated 1 or more time
with
single-quote followed by a string newdate

1 - make the above substitution ONLY for the FIRST matched pattern

Last edited by vgersh99; 04-01-2011 at 05:43 PM..
This User Gave Thanks to vgersh99 For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Keeping padding in a date field

Hi Guys, I'm having a bit of a problem with a script, i need to get the day, month and day of month into a string, so i'm using: CURRENT_DATE=`date +"%a %b %e"` It is getting the correct date out, however it is not keeping the padding on the day of month. The %e is supposed to pad the day... (5 Replies)
Discussion started by: seanbyrne
5 Replies

2. 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

3. 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

4. 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

5. UNIX for Dummies Questions & Answers

Replace some strings keeping others

I want to replace strings in test2 according to test1 table. In doing so, I`m losing records that I dont need to replace, please suggest modifications. what i have $ cat > test1 a b c d   $ cat > test2 a a a d d   what i tried $ awk ' BEGIN {FS=OFS=" "} FNR==NR{a=$2;next}... (2 Replies)
Discussion started by: senhia83
2 Replies

6. 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

7. 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

8. 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

9. 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
MouseX::NativeTraits::Str(3pm)				User Contributed Perl Documentation			    MouseX::NativeTraits::Str(3pm)

NAME
MouseX::NativeTraits::Str - Helper trait for Str attributes SYNOPSIS
package MyHomePage; use Mouse; has 'text' => ( traits => ['String'], is => 'rw', isa => 'Str', default => q{}, handles => { add_text => 'append', replace_text => 'replace', }, ); my $page = MyHomePage->new(); $page->add_text("foo"); # same as $page->text($page->text . "foo"); DESCRIPTION
This module provides a simple string attribute, to which mutating string operations can be applied more easily (no need to make an lvalue attribute metaclass or use temporary variables). Additional methods are provided for completion. PROVIDED METHODS
These methods are implemented in MouseX::NativeTraits::MethodProvider::Str. It is important to note that all those methods do in place modification of the value stored in the attribute. inc Increments the value stored in this slot using the magical string autoincrement operator. Note that Perl doesn't provide analogous behavior in "--", so "dec" is not available. append($string) Append a string, like ".=". prepend($string) Prepend a string. replace($pattern, $replacement) Performs a regexp substitution ("s" in perlop). A code references will be accepted for the replacement, causing the regexp to be modified with a single "e". "/smxi" can be applied using the "qr" operator. replace($pattern, $replacement) Performs a regexp substitution ("s" in perlop) with the "g" flag. A code references will be accepted for the replacement, causing the regexp to be modified with a single "e". "/smxi" can be applied using the "qr" operator. match($pattern) Like "replace" but without the replacement. Provided mostly for completeness. chop "chop" in perlfunc chomp "chomp" in perlfunc clear Sets the string to the empty string (not the value passed to "default"). length "length" in perlfunc substr "substr" in perlfunc. We go to some lengths to match the different functionality based on "substr"'s arity. METHODS
meta method_provider_class helper_type SEE ALSO
MouseX::NativeTraits perl v5.14.2 2011-12-04 MouseX::NativeTraits::Str(3pm)
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy