Sponsored Content
Top Forums Shell Programming and Scripting awk/sed Command : Parse parameter file / send the lines to the ksh export command Post 302255453 by rajan_san on Thursday 6th of November 2008 12:27:04 PM
Old 11-06-2008
I was able to get through this issue using the eval option

for LINE in `sed -n '/ '${DB}' /,/ End /p' infile| grep -v ^#`; do
eval `echo "export " ${LINE}`
done

Thanks
Rajan
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Passing Parameter in SED command

Hi, I am trying to replace a URL by another URL in the SED command e.g. cat dir/filename1 | sed -e 's/"http:\/\/*dtd"/"http:\/\/abc.def.com\/xyz.dtd"/' > dir/newfile.xml But I need to pass a parameter to the SED command which should have the new url string i.e.... (2 Replies)
Discussion started by: dsrookie
2 Replies

2. Shell Programming and Scripting

awk/sed Command: To Parse Stament between 2 numbers

Hi, I need an awk command that would parse the below expression Input Format 1 'Stmt1 ............................'2 'Stmt2 ............................'3 'Stmt3 ............................'4 'Stmt4 ............................'5 'Stmt5 ............................'6 'Stmt6... (1 Reply)
Discussion started by: rajan_san
1 Replies

3. Shell Programming and Scripting

sed command to parse Apache config file

Hi there, am trying to parse an Apache 'server' config file. A snippet of the config file is shown below: ..... ProxyPassReverse /foo http://foo.example.com/bar ..... ..... RewriteRule ^/(.*) http://www.example.com/$1 RewriteRule /redirect https://www.example1.com/$1 ........ (7 Replies)
Discussion started by: jy2k7ca
7 Replies

4. Shell Programming and Scripting

Command to remove duplicate lines with perl,sed,awk

Input: hello hello hello hello monkey donkey hello hello drink dance drink Output should be: hello hello monkey donkey drink dance (9 Replies)
Discussion started by: cola
9 Replies

5. Shell Programming and Scripting

sed command removes lines in file

Hi, I am modifying a file with sed command. i want to make SCORE= blank in the file whereever SCORE=somevalue. What will *$ do in the below command? cat $file | sed 's/SCORE=.*$/SCORE=\r/g' > newfile The last line is also missing in the new file. How to make SCORE='100' to SCORE=... (5 Replies)
Discussion started by: ashok.k
5 Replies

6. UNIX for Dummies Questions & Answers

How to parse 2 particular lines from Command output

Hi All, I need help on the following req. I am getting output of a command as follows: 16377612 total memory 3802460 used memory 2827076 active memory 681948 inactive memory 12575152 free memory 477452 buffer memory I want to compute used... (1 Reply)
Discussion started by: mailsara
1 Replies

7. Shell Programming and Scripting

AWK Command parse a file based on string.

AWK Command parse a file based on string. I am trying to write a shell script to parse a file based on a string and move the content of the file to another file. Here is scenario. File content below Mime-Version: 1.0 Content-Type: multipart/mixed; ... (2 Replies)
Discussion started by: aakishore
2 Replies

8. Shell Programming and Scripting

Sed/awk/perl command to replace pattern in multiple lines

Hi I know sed and awk has options to give range of line numbers, but I need to replace pattern in specific lines Something like sed -e '1s,14s,26s/pattern/new pattern/' file name Can somebody help me in this.... I am fine with see/awk/perl Thank you in advance (9 Replies)
Discussion started by: dani777
9 Replies

9. Shell Programming and Scripting

Need awk/sed command to pull out matching lines from a block

Hi, In order to make our debugging easier in log files, I need this script. My log file will be structured like this : ------Invoking myfile -param:start_time=1371150900000 -param:end_time=1371151800000 for 06/14/2013 <multiple lines here> ..... - Step Sybase CDR Table.0 ended... (3 Replies)
Discussion started by: Lakshmikumari
3 Replies

10. Shell Programming and Scripting

Sed/awk command to convert number occurances into date format and club a set of lines

Hi, I have been stuck in this requirement where my file contains the below format. 20150812170500846959990854-25383-8.0.0 "ABC Report" hp96880 "4952" 20150812170501846959990854-25383-8.0.0 End of run 20150812060132846959990854-20495-8.0.0 "XYZ Report" vg76452 "1006962188"... (6 Replies)
Discussion started by: Chinmaya Kabi
6 Replies
Perl::Critic::Policy::ErrorHandling::RequireCheckingRetuUserlContributedPerl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval(3pm)

NAME
Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval - You can't depend upon the value of "$@"/"$EVAL_ERROR" to tell whether an "eval" failed. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
A common idiom in perl for dealing with possible errors is to use "eval" followed by a check of $@/$EVAL_ERROR: eval { ... }; if ($EVAL_ERROR) { ... } There's a problem with this: the value of $EVAL_ERROR can change between the end of the "eval" and the "if" statement. The issue is object destructors: package Foo; ... sub DESTROY { ... eval { ... }; ... } package main; eval { my $foo = Foo->new(); ... }; if ($EVAL_ERROR) { ... } Assuming there are no other references to $foo created, when the "eval" block in "main" is exited, "Foo::DESTROY()" will be invoked, regardless of whether the "eval" finished normally or not. If the "eval" in "main" fails, but the "eval" in "Foo::DESTROY()" succeeds, then $EVAL_ERROR will be empty by the time that the "if" is executed. Additional issues arise if you depend upon the exact contents of $EVAL_ERROR and both "eval"s fail, because the messages from both will be concatenated. Even if there isn't an "eval" directly in the "DESTROY()" method code, it may invoke code that does use "eval" or otherwise affects $EVAL_ERROR. The solution is to ensure that, upon normal exit, an "eval" returns a true value and to test that value: # Constructors are no problem. my $object = eval { Class->new() }; # To cover the possiblity that an operation may correctly return a # false value, end the block with "1": if ( eval { something(); 1 } ) { ... } eval { ... 1; } or do { # Error handling here }; Unfortunately, you can't use the "defined" function to test the result; "eval" returns an empty string on failure. Various modules have been written to take some of the pain out of properly localizing and checking $@/$EVAL_ERROR. For example: use Try::Tiny; try { ... } catch { # Error handling here; # The exception is in $_/$ARG, not $@/$EVAL_ERROR. }; # Note semicolon. "But we don't use DESTROY() anywhere in our code!" you say. That may be the case, but do any of the third-party modules you use have them? What about any you may use in the future or updated versions of the ones you already use? CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
See thread on perl5-porters starting here: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2008-06/msg00537.html <http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2008-06/msg00537.html>. For a nice, easy, non-magical way of properly handling exceptions, see Try::Tiny. AUTHOR
Elliot Shank "<perl@galumph.com>" COPYRIGHT
Copyright (c) 2008-2011 Elliot Shank. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.14.2 2012Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval(3pm)
All times are GMT -4. The time now is 10:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy