Hello,
I am trying to replace a string with a paramter given along with the script.
I am replacing application1 to application2 with the script:
./change_app.sh application2
change_app.sh:
#!/bin/ksh
grep $1 applications.dat 2>&1 >/dev/null
echo $1
file=pckage.new
sed 's/Name:... (5 Replies)
hii,
i need a unix command which replaces all occurrences of a substring within a string with another substring.
My solution:
string="plalstalplal"
sub1="al"
sub2="mlkl"
echo sed 's/$s2/$s3/g' < s1 > p
i want to know how to read the variables s2 and s3..
thaks a lot
bye (1 Reply)
Hello All,
How to replace a string in nth line of a file using sed or awk.
For Ex: test.txt
Line 1 : TEST1 TEST2 TEST3
Line 2 : TEST1 TEST2 TEST3 TEST4
Line 3 : TEST1 TEST2 TEST3 TEST5
Line 4 : TEST1 TEST2 TEST3 TEST6
Line 5 : TEST1 TEST2 TEST3 TEST7
i want to go to 4th line of a... (1 Reply)
hi,
when i am doing the following things getting error
Can anyone please suggest
i have a file where there is a line like the following
branch=dev sdf dev jin kilii fin kale boyle dev james dev
i want to search the existance of dev in the above line.
cat "$file" | sed -n... (8 Replies)
hi,
i currently have a file with columns similar to this
customer name owed
CID123 John 300
CID342 harry 500
at present i use use awk to find the amount owed by the customer using the customer ID (CID).
if the customer spends more money how would i go about using sed/awk etc to... (2 Replies)
I have following set of dirs:
/dir1/dir2/subdir1
file1
file2
/dir1/dir3/subdir1
file4
file5
/dir1/dir4/subdir1
file6
file7
All of these files have a common string in them say "STRING1", How can I... (3 Replies)
Dear all,
I have a file like below. I want to replace all the '.' in the 3rd column with 'NA'. I don't know how to do that. Anyone has an iead? Thanks a lot!
8 70003200 21.6206
9 70005700 17.5064
10 70002200 .
11 70005100 19.1001
17 70008000 16.1970
32 70012400 26.3465
33... (9 Replies)
Hi All,
As mentioned in the title I have two text files and I would like to replace line number 5 of file #1 with line number 4 of file #2
e.g.
file 1
wqwert
4.4464002
3
319
286
369
46.320002
56.150002
45.100002
1
1
1
0.723 (12 Replies)
Hi All,
I have below requirement:
I need to read each line in file.txt and replace string starting from position 9 to 24 {111111111111111,222222222222222,333333333333333} by common string "444444444444444" and save file.
File.txt:
03000003111111111111111 ... (3 Replies)
Hi,
I have a file which is an extract of jil codes of all autosys jobs in our server.
Sample jil code:
**************************
permission:gx,wx
date_conditions:yes
days_of_week:all
start_times:"05:00"
condition: notrunning(appDev#box#ProductLoad)... (1 Reply)
Discussion started by: raghavendra
1 Replies
LEARN ABOUT DEBIAN
class::gomor::hash
Class::Gomor::Hash(3pm) User Contributed Perl Documentation Class::Gomor::Hash(3pm)NAME
Class::Gomor::Hash - class and object builder, hash version
SYNPOSIS
# Create a base class in BaseClass.pm
package My::BaseClass;
require Class::Gomor::Hash;
our @ISA = qw(Class::Gomor::Hash);
our @AS = qw(attribute1 attribute2);
our @AA = qw(attribute3 attribute4);
our @AO = qw(other);
# You should initialize yourself array attributes
sub new { shift->SUPER::new(attribute3 => [], attribute4 => [], @_) }
# Create accessors
My::BaseClass->cgBuildAccessorsScalar(@AS);
My::BaseClass->cgBuildAccessorsArray(@AA);
sub other {
my $self = shift;
@_ ? $self->{'other'} = [ split(/
/, shift) ]
: @{$self->{'other'}};
}
1;
# Create a subclass in SubClass.pm
package My::SubClass;
require My::BaseClass;
our @ISA = qw(My::BaseClass);
our @AS = qw(subclassAttribute);
My::SubClass->cgBuildAccessorsScalar(@AS);
sub new {
shift->SUPER::new(
attribute1 => 'val1',
attribute2 => 'val2',
attribute3 => [ 'val3', ],
attribute4 => [ 'val4', ],
other => [ 'none', ],
subclassAttribute => 'subVal',
);
}
1;
# A program using those classes
my $new = My::SubClass->new;
my $val1 = $new->attribute1;
my @values3 = $new->attribute3;
my @otherOld = $new->other;
$new->other("str1
str2
str3");
my @otherNew = $new->other;
print "@otherNew
";
$new->attribute2('newValue');
$new->attribute4([ 'newVal1', 'newVal2', ]);
DESCRIPTION
This class is a subclass from Class::Gomor. It implements objects as hash references, and inherits methods from Class::Gomor.
GLOBAL VARIABLE
See Class::Gomor.
METHODS
new (hash)
Object constructor. This is where user passed attributes (hash argument) are checked against valid attributes (gathered by
cgGetAttributes method). Valid attributes are those that exists (doh!), and have not an undef value. The default is to check this, you
can avoid it by setting $NoCheck global variable (see perldoc Class::Gomor).
cgBuildIndices
This method does nothing. It only exists to make it more easy to switch between Class::Gomor::Array and Class::Gomor::Hash.
cgBuildAccessorsScalar (array ref)
cgBuildAccessorsArray (array ref)
See Class::Gomor.
cgGetIndice (scalar)
This method does nearly nothing. It only returns the passed-in scalar parameter (so the syntax is the same as in Class::Gomor::Array).
It only exists to make it more easy to switch between Class::Gomor::Array and Class::Gomor::Hash.
cgClone [ (scalar) ]
You can clone one of your objects by calling this method. An optional parameter may be used to create multiple clones. Cloning will
occure only on the first level attributes, that is, if you have attributes containing other objects, they will not be cloned.
cgFullClone [ (scalar) ]
This method is the same as cgClone, but will clone all attributes recursively, but only if they are subclassed from Class::Gomor. So,
objects created with other modules than Class::Gomor::Array or Class::Gomor::Hash will not be cloned.
Another thing to note, there is no catch for cycling references (when you link two objects with each others). You have been warned.
cgDumper
Will return a string as with Data::Dumper Dumper method. This is less useful for hashref objects, because they already include
attributes names.
SEE ALSO
Class::Gomor
AUTHOR
Patrice <GomoR> Auffret
COPYRIGHT AND LICENSE
Copyright (c) 2004-2009, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.
perl v5.10.1 2009-05-23 Class::Gomor::Hash(3pm)