Sponsored Content
Top Forums UNIX for Advanced & Expert Users Substitution when special charcters involved Post 302258225 by spirtle on Friday 14th of November 2008 04:52:41 AM
Old 11-14-2008
With sed you can use any character as the pattern separator, e.g. you can replace / with |
Code:
sed -e "s|Bob's birthday 13/11/08 (today)|Bob's birthday 14/11/08 (tomorrow)|" file1

See e.g.
https://www.unix.com/shell-programmin...#post302244111
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help! a free Sprite is involved!

Can anyone define the following for me? /etc/rc.c/init.d/iptables restart Our resident "Geek" is giving away a prize if I can tell him what this means. (5 Replies)
Discussion started by: txyzzy
5 Replies

2. HP-UX

How to check patches involved

Hi I need to check if the following patches are installed in a HP-UX machine "GOLDQPK11i, which in turn includes both GOLDAPPS11i and GLODBASE11i How can I go about doing it, am still a struggling sys admin! Saw this command showrev -p but command not found in the machine thou! Thanks... (3 Replies)
Discussion started by: gelbvonn
3 Replies

3. Solaris

Handling Special Charcters

Dear All, I have created a UTF-8 database to store multi-lingual charcters. Below is the query from which i insert from Winsql (front-end third party database browser tool), the data gets inserted properly. insert into a (no, lbl) values (1, "Cliquez ici pour revenir Ã_ la recherche de... (2 Replies)
Discussion started by: lloydnwo
2 Replies

4. UNIX for Advanced & Expert Users

remove charcters

How do i remove single quotes(') from a file. Can we use sed for it (2 Replies)
Discussion started by: kris01752
2 Replies

5. UNIX for Advanced & Expert Users

Line Longer Than 2048 Charcters

I have a csv file with a record size of greater than 2048.So when i try to open the file in VI..This is the error i get (test.csv" A line cannot be longer than 2048 characters) Is there a way i can change this parameter to read a bigger line (2 Replies)
Discussion started by: kris01752
2 Replies

6. Shell Programming and Scripting

cat in linux, file holding special charcters

Hi I'd like to cat, in linux, a file that holds special charcters, like "-->" and ">" and "]" For example I have a file named test123.txt it looks like this: 2008-09-11 00:27:01,496 - < 0 > --> Start calculation of pattern , Pattern was split to pattern graphs < 0 > System Tqls Optimizer... (5 Replies)
Discussion started by: liav
5 Replies

7. Solaris

nestat on server involved in high traffic network

Hi All My Server is doing a very intense netowrk traffic operations and the cards are under very high pressure. I need to call NETSTAT on the shell. Do you know whether this command, under high pressure, might have some impact on the server traffic or can I proceed without any problem? (2 Replies)
Discussion started by: manustone
2 Replies

8. UNIX for Dummies Questions & Answers

Meta charcters

Find out lines in a given file consisting of the following pattern BCAA, BCAAA, BCAAAA, BCAAAAA, BCAAAAAA (0 Replies)
Discussion started by: Phaneendra G
0 Replies

9. Homework & Coursework Questions

Meta charcters

find out lines in a given file consisting of the following pattern BCAA, BCAAA, BCAAAA, BCAAAAA, BCAAAAAA (1 Reply)
Discussion started by: Phaneendra G
1 Replies

10. Shell Programming and Scripting

awk statement to grep (bit involved)

Hellow: I have the following data. id1 xxx xxx xxx id1 xxxx xxx xxx id2 xxx xxx xxx id2 xxxx xxx xxx id2 In my awk script which reads the file containing the above data I have the following code: myline=<inputdata> which is shown above What I am trying to find out is how may... (5 Replies)
Discussion started by: wincrazy
5 Replies
Rose::Object::MakeMethods::DateTime(3pm)		User Contributed Perl Documentation		  Rose::Object::MakeMethods::DateTime(3pm)

NAME
Rose::Object::MakeMethods::DateTime - Create methods that store DateTime objects. SYNOPSIS
package MyObject; use Rose::Object::MakeMethods::DateTime ( datetime => [ 'birthday', 'arrival' => { tz => 'UTC' } ], ); ... $obj = MyObject->new(birthday => '1/24/1984 1am'); $dt = $obj->birthday; # DateTime object $bday = $obj->birthday(format => '%B %E'); # 'January 24th' # Shortcut for $obj->birthday->clone->truncate(to => 'month'); $month = $obj->birthday(truncate => 'month'); $obj->birthday('blah'); # croaks - invalid date! $obj->birthday('1999-04-31'); # croaks - invalid date! DESCRIPTION
Rose::Object::MakeMethods::DateTime is a method maker that inherits from Rose::Object::MakeMethods. See the Rose::Object::MakeMethods documentation to learn about the interface. The method types provided by this module are described below. All methods work only with hash-based objects. METHODS TYPES
datetime Create get/set methods for scalar attributes that store DateTime objects. Options "hash_key" The key inside the hash-based object to use for the storage of this attribute. Defaults to the name of the method. "init_method" The name of the method to call when initializing the value of an undefined attribute. This option is only applicable when using the "get_set_init" interface. Defaults to the method name with the prefix "init_" added. This method should return a value that can be parsed by Rose::DateTime::Util's the parse_date() function. If the return value is a DateTime object, it will have its time zone set (see the "tz" option below) using DateTime's set_time_zone() method. "interface" Chooses one of the two possible interfaces. Defaults to "get_set". "tz" The time zone of the DateTime object to be stored. If present, this value will be passed as the second argument to Rose::DateTime::Util's the parse_date() function when creating DateTime objects for storage. If absent, DateTime objects will use the default time zone of the Rose::DateTime::Util class, which is set by Rose::DateTime::Util's time_zone() class method. See the Rose::DateTime::Util documentation for more information. Interfaces "get_set" Creates a get/set accessor method for an object attribute that stores a DateTime object. When called with a single argument, the argument is passed through Rose::DateTime::Util's parse_date() function in order to create the DateTime object that is stored. The current value of the attribute is returned. Passing a value that is not understood by Rose::DateTime::Util's parse_date() function causes a fatal error. When called with two arguments and the first argument is the string 'format', then the second argument is taken as a format specifier which is passed to Rose::DateTime::Util's format_date() function. The formatted string is returned. In other words, this: $obj->birthday(format => '%m/%d/%Y'); Is just a shortcut for this: Rose::DateTime::Util::format_date($obj->birthday, '%m/%d/%Y'); When called with two arguments and the first argument is the string 'truncate', then the second argument is taken as a truncation specifier which is passed to DateTime's truncate() method called on a clone of the existing DateTime object. The cloned, truncated DateTime object is returned. In other words, this: $obj->birthday(truncate => 'month'); Is just a shortcut for this: $obj->birthday->clone->truncate(to => 'month'); Passing more than two arguments or passing two arguments where the first argument is not 'format' or 'truncate' will cause a fatal error. "get_set_init" Behaves like the "get_set" interface unless the value of the attribute is undefined. In that case, the method specified by the "init_method" option is called, the return value is passed through Rose::DateTime::Util's parse_date() function, and the attribute is set to the return value. An init method that returns a value that is not understood by Rose::DateTime::Util's parse_date() function will cause a fatal error. Example: package MyObject; use Rose::Object::MakeMethods::DateTime ( datetime => [ 'birthday', 'arrival' => { tz => 'UTC' } ], 'datetime --get_set_init' => [ 'departure' => { tz => 'UTC' } ], ); sub init_departure { DateTime->new(month => 1, day => 10, year => 2000, time_zone => 'America/Chicago'); } ... $obj = MyObject->new(birthday => '1/24/1984 1am'); $dt = $obj->birthday; # DateTime object $bday = $obj->birthday(format => '%B %E'); # 'January 24th' # Shortcut for $obj->birthday->clone->truncate(to => 'month'); $month = $obj->birthday(truncate => 'month'); $obj->birthday('blah'); # croaks - invalid date! $obj->birthday('1999-04-31'); # croaks - invalid date! # DateTime object with time zone set to UTC $dt = $obj->arrival('2005-21-01 4pm'); # DateTime object with time zone set to UTC, not America/Chicago! # Start with 2000-01-10T00:00:00 America/Chicago, # then set_time_zone('UTC'), # which results in: 2000-01-10T06:00:00 UTC $dt = $obj->departure; print $dt; # "2000-01-10T06:00:00" AUTHOR
John C. Siracusa (siracusa@gmail.com) LICENSE
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-10-17 Rose::Object::MakeMethods::DateTime(3pm)
All times are GMT -4. The time now is 02:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy