06-24-2009
search and replace characters in one string
I have lines like:
Dog Cat House Mouse
Dog Cat House Mouse
Dog Cat House Mouse
Dog Cat House Mouse
I'd like to replace characters only in $3.
H -> Z
s -> W
e -> x
Resulting in something like (where $1, $2, and $4 are not changed):
Dog Cat ZouWx Mouse
Dog Cat ZouWx Mouse
Dog Cat ZouWx Mouse
Dog Cat ZouWx Mouse
I'd guess SED might be best but I'm really new. Sorry to to include any sample code.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text.
An example of 4 lines in my file is:
1. MatchText_randomNumberOfText moreData ReplaceMe moreData
2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies
2. UNIX for Dummies Questions & Answers
Hi All,
My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found in the same file..The... (27 Replies)
Discussion started by: ganesh_248
27 Replies
3. Shell Programming and Scripting
Hello: I have another question. Please consider the following two sample, tab-delimited files:
File_1:
Abf1 YKL112w
Abf1 YAL054c
Abf1 YGL234w
Ace2 YKL150w
Ace2 YNL328c
Cup9 YDR441c
Cup9 YDR442w
Cup9 YEL040w
...
File 2:
...
ABF1 YKL112W
ACE2 YLR131C (9 Replies)
Discussion started by: gstuart
9 Replies
4. Shell Programming and Scripting
Hello,
I really would appreciate some help with a bash script for some string manipulation on an SQL dump:
I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump.
This is quite easy with sed:
sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies
5. Shell Programming and Scripting
Masters,
I have fixed length input file like FHEAD0000000001XXXX20090901 0000009000Y1000XXX2
THEAD000000000220090901 ITM0000109393813 430143504352N22SP 000000000000RN000000010000EA P0000000000000014390020090901
TTAIL0000000003000000
FTAIL00000000040000000002
Note... (4 Replies)
Discussion started by: bittoo
4 Replies
6. Shell Programming and Scripting
How would I accomplish this if I want to test to see if it
1) starts with a dash so something like "-R"
AND
2) starts with 1 character then either a "-" or "+" and then up to 3 characters such as "a+rx" (3 Replies)
Discussion started by: mkjp2011
3 Replies
7. Shell Programming and Scripting
We are getting extended Ascii characters in the input file and my requirement is to search and replace them with a space. I am using the following command
LANG=C sed -e 's// /g'
It is doing a good job, but in some cases it is replacing the extended characters with two spaces. So my input... (12 Replies)
Discussion started by: ysvsr1
12 Replies
8. Shell Programming and Scripting
1st_FILE.cnf
Here is my sample test file .
This will be replaced by .
2nd_FILE.cnf
This is my 2nd test file ..This is agian a test file for purpose.
variable.txt
TST_FILE=1st_FILE.txt
FILE_NAME=1st_FILE.txt
2ND_TST_FILE=2nd_FILE.txt
REASON=test
I have 2 sample config file under... (13 Replies)
Discussion started by: manas_ranjan
13 Replies
9. UNIX for Dummies Questions & Answers
Hi Everyone,
I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file.
I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies
10. UNIX for Beginners Questions & Answers
I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this.
string(Scenario 1)- user::r--,user::ourfrd:r--
String(Scenario 2)- user::r--
File
****
# file: /local/Desktop/myfile
# owner: me
# group:... (6 Replies)
Discussion started by: sarathy_a35
6 Replies
LEARN ABOUT DEBIAN
mouse::spec
Mouse::Spec(3pm) User Contributed Perl Documentation Mouse::Spec(3pm)
NAME
Mouse::Spec - To what extent Mouse is compatible with Moose
VERSION
This document describes Mouse version 0.99
SYNOPSIS
use Mouse::Spec;
printf "Mouse/%s is compatible with Moose/%s
",
Mouse::Spec->MouseVersion, Mouse::Spec->MooseVersion;
DESCRIPTION
Mouse is a subset of Moose. This document describes to what extend Mouse is compatible (and incompatible) with Moose.
Compatibility with Moose
Sugary APIs
The sugary APIs are highly compatible with Moose. Methods which have the same name as Moose's are expected to be compatible with Moose's.
Meta object protocols
Meta object protocols are a subset of the counterpart of Moose. Their methods which have the same name as Moose's are expected to be
compatible with Moose's. Feel free to use these methods even if they are not documented.
However, there are differences between Moose's MOP and Mouse's. For example, meta object protocols in Mouse have no attributes by default,
so "$metaclass->meta->make_immutable()" will not work as you expect. Don not make metaclasses immutable.
Mouse::Meta::Instance
Meta instance mechanism is not implemented, so you cannot change the reftype of Mouse objects in the same way as Moose.
Role exclusion
Role exclusion, "exclude()", is not implemented.
-metaclass in Mouse::Exporter
"use Mouse -metaclass => ..." are not implemented. Use "use Mouse -traits => ..." instead.
Mouse::Meta::Attribute::Native
Native traits are not supported directly, but "MouseX::NativeTraits" is available on CPAN. Once you have installed it, you can use it as
the same way in Moose. That is, native traits are automatically loaded by Mouse.
See MouseX::NativeTraits for details.
Notes about Moose::Cookbook
Many recipes in Moose::Cookbook fit Mouse, including:
o Moose::Cookbook::Basics::Recipe1 - The (always classic) Point example
o Moose::Cookbook::Basics::Recipe2 - A simple BankAccount example
o Moose::Cookbook::Basics::Recipe3 - A lazy BinaryTree example
o Moose::Cookbook::Basics::Recipe4 - Subtypes, and modeling a simple Company class hierarchy
o Moose::Cookbook::Basics::Recipe5 - More subtypes, coercion in a Request class
o Moose::Cookbook::Basics::Recipe6 - The augment/inner example
o Moose::Cookbook::Basics::Recipe7 - Making Moose fast with immutable
o Moose::Cookbook::Basics::Recipe8 - Builder methods and lazy_build
o Moose::Cookbook::Basics::Recipe9 - Operator overloading, subtypes, and coercion
o Moose::Cookbook::Basics::Recipe10 - Using BUILDARGS and BUILD to hook into object construction
o Moose::Cookbook::Roles::Recipe1 - The Moose::Role example
o Moose::Cookbook::Roles::Recipe2 - Advanced Role Composition - method exclusion and aliasing
o Moose::Cookbook::Roles::Recipe3 - Applying a role to an object instance
o Moose::Cookbook::Meta::Recipe2 - A meta-attribute, attributes with labels
o Moose::Cookbook::Meta::Recipe3 - Labels implemented via attribute traits
o Moose::Cookbook::Extending::Recipe3 - Providing an alternate base object class
SEE ALSO
Mouse
Moose
Moose::Manual
Moose::Cookbook
perl v5.14.2 2012-06-30 Mouse::Spec(3pm)