Sponsored Content
Full Discussion: changes values in a file
Top Forums UNIX for Advanced & Expert Users changes values in a file Post 302501253 by balapobi on Thursday 3rd of March 2011 07:01:03 AM
Old 03-03-2011
changes values in a file

search and replace the new values in file

abc/xxx/456/desc_1 int integer = 4400000
acc/xxx/456/rss int integer = 400
abc/xxx/123/data_2 int integer = 5000000
acc/xxx/456/rss int integer = 400
abc/xxx/789/data_3 int integer = 1000000
acc/xxx/456/rss int integer = 400


I need to change the 7 digit numeric values in a file to default value. example 10000

output should be
abc/xxx/456/desc_1 int integer = 10000
acc/xxx/456/rss int integer = 400
abc/xxx/123/data_2 int integer = 10000
acc/xxx/456/rss int integer = 400
abc/xxx/789/data_3 int integer = 10000
acc/xxx/456/rss int integer = 400

Regards
Bala
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PERL:How to convert numeric values txt file to PACKED DECIMAL File?

Is there any way to convert numeric values txt file to PACKED DECIMAL File using PERL. Regards, Alok (1 Reply)
Discussion started by: aloktiwary
1 Replies

2. Shell Programming and Scripting

Replacing values in a file based on values in another file

Hi I have 2 files:- 1. List of files which consists of names of some output files. 2. A delimited file; delimted by "|" I want to replace the value of the $23 (23rd column) in the delimited file with name in the first file. It is always position to position. Meaning first row of the first... (5 Replies)
Discussion started by: pparthiv
5 Replies

3. Shell Programming and Scripting

remove values of a file one by one from 2nd file and then print the remaining values of 2nd file

Hi all, I have 2 files. One contains only 1 column and other one contains 2 columns, let say 1_col.txt and 2_col.txt respectively. Here, I will try to explain with an example. Input files : 1_col.txt 2_col.txt a a b x a c p ... (5 Replies)
Discussion started by: AshwaniSharma09
5 Replies

4. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

5. Shell Programming and Scripting

Referencing file for values and referencing another file to replace values

Hi I have a file which has values in each line: MP304,d40000 MP310,ff0000 etc I have another file which as the first value in it and is unique in the file(not repeated). I need to replace a string with the second value above. The second file contents is as follows:(snippet) <g ... (12 Replies)
Discussion started by: majikins
12 Replies

6. Shell Programming and Scripting

Replace values in a file with values from another file

Hi, I have 2 input files: File 1: echo Name > create_Name.txt echo Group /dir/group, Name >> create_Name.txt File 2: Name AAA BBB CCC group A B C dir A1 B1 C1 ................................ Need to replace the contents of File 1 with column 2, 3 & 4 values of File 2... (8 Replies)
Discussion started by: gctex
8 Replies

7. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

8. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

9. UNIX for Dummies Questions & Answers

Reading Xml file and print the values into the text file in columnwise?

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (4 Replies)
Discussion started by: sravanreddy
4 Replies

10. Shell Programming and Scripting

Taking key values from one file and extracting values from another file

Hi, I have two files with values in both. File1: cat 2 3 dog 4 5 elephant 6 7 camel 2 3 File2: ----+--gkf;ajf= ---+---- +----- cat -------=----+ 3 | 4 ----- dog ------++-- 5 | 9 ----++-- elephant | 5 | 7 ---++ camel ------ ++++_---- || 8 | 9 I want the final file as: cat 4... (1 Reply)
Discussion started by: npatwardhan
1 Replies
Pragmatic(3pm)						User Contributed Perl Documentation					    Pragmatic(3pm)

NAME
Pragmatic - Adds pragmata to Exporter SYNOPSIS
In module MyModule.pm: package MyModule; require Pragmatic; @ISA = qw (Pragmatic); %PRAGMATA = (mypragma => sub {...}); In other files which wish to use MyModule: use MyModule qw (-mypragma); # Execute pragma at import time use MyModule qw (-mypragma=1,2,3); # Pass pragma argument list DESCRIPTION
Pragmatic implements a default "import" method for processing pragmata before passing the rest of the import to Exporter. Perl automatically calls the "import" method when processing a "use" statement for a module. Modules and "use" are documented in perlfunc and perlmod. (Do not confuse Pragmatic with pragmatic modules, such as less, strict and the like. They are standalone pragmata, and are not associated with any other module.) Using Pragmatic Modules Using Pragmatic modules is very simple. To invoke any particular pragma for a given module, include it in the argument list to "use" preceded by a hyphen: use MyModule qw (-mypragma); "Pragmatic::import" will filter out these arguments, and pass the remainder of the argument list from the "use" statement to "Exporter::import" (actually, to "Exporter::export_to_level" so that Pragmatic is transparent). If you want to pass the pragma arguments, use syntax similar to that of the -M switch to perl (see perlrun): use MyModule qw (-mypragma=abc,1,2,3); If there are any warnings or fatal errors, they will appear to come from the "use" statement, not from "Pragmatic::import". Writing Pragmatic Modules Writing Pragmatic modules with Pragmatic is straight-forward. First, "require Pragmatic" (you could "use" it instead, but it exports nothing, so there is little to gain thereby). Declare a package global %PRAGMATA, the keys of which are the names of the pragmata and their corresponding values the code references to invoke. Like this: package MyPackage; require Pragmatic; use strict; use vars qw (%PRAGMATA); sub something_else { 1; } %PRAGMATA = (first => sub { print "@_: first "; }, second => sub { $SOME_GLOBAL = 1; }, third => &something_else, fourth => 'name_of_sub'); When a pragma is given in a "use" statement, the leading hyphen is removed, and the code reference corresponding to that key in %PRAGMATA, or a subroutine with the value's name, is invoked with the name of the package as the first member of the argument list (this is the same as what happens with "import"). Additionally, any arguments given by the caller are included (see "Using Pragmatic Modules", above). EXAMPLES
Using Pragmatic Modules 1. Simple use: use MyModule; # no pragmas use MyModule qw (-abc); # invoke C<abc> use MyModule qw (-p1 -p2); # invoke C<p1>, then C<p2> 2. Using an argument list: use MyModule qw (-abc=1,2,3); # invoke C<abc> with (1, 2, 3) use MyModule qw (-p1 -p2=here); # invoke C<p1>, then C<p2> # with (1, 2, 3) 3. Mixing with arguments for Exporter: (Please see Exporter for a further explanatation.) use MyModule ( ); # no pragmas, no exports use MyModule qw (fun1 -abc fun2); # import C<fun1>, invoke C<abc>, # then import C<fun2> use MyModule qw (:set1 -abc=3); # import set C<set1>, invoke C<abc> # with(3) Writing Pragmatic Modules 1. Setting a package global: %PRAGMATA = (debug => sub { $DEBUG = 1; }); 2. Selecting a method: my $fred = sub { 'fred'; }; my $barney = sub { 'barney'; }; %PRAGMATA = (fred => sub { local $^W = 0; *flintstone = $fred; }, barney => sub { local $^W = 0; *flintstone = $barney; }); 3. Changing inheritance: %PRAGMATA = (super => sub { shift; push @ISA, @_; }); 4. Inheriting pragmata: package X; @ISA = qw(Pragmatic); %PRAGMATA = (debug => 'debug'); $DEBUG = 0; sub debug { ${"$_[0]::DEBUG"} = 1; } package Y: @ISA = qw(X); %PRAGMATA = (debug => 'debug'); $DEBUG = 0; SEE ALSO
Exporter Exporter does all the heavy-lifting (and is a very interesting module to study) after Pragmatic has stripped out the pragmata from the "use". DIAGNOSTICS
The following are the diagnostics generated by Pragmatic. Items marked "(W)" are non-fatal (invoke "Carp::carp"); those marked "(F)" are fatal (invoke "Carp::croak"). No such pragma '%s' (F) The caller tried something like "use MyModule (-xxx)" where there was no pragma xxx defined for MyModule. Invalid pragma '%s' (F) The writer of the called package tried something like "%PRAGMATA = (xxx => not_a_sub)" and either assigned xxx a non-code reference, or xxx is not a method in that package. Pragma '%s' failed (W) The pramga returned a false value. The module is possibly in an inconsisten state after this. Proceed with caution. AUTHORS
B. K. Oxley (binkley) <binkley@alumni.rice.edu> COPYRIGHT
Copyright 1999-2005, B. K. Oxley. This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself. THANKS
Thanks to Kevin Caswick <KCaswick@wspackaging.com> for a great patch to run under Perl 5.8. perl v5.10.1 2009-12-09 Pragmatic(3pm)
All times are GMT -4. The time now is 06:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy