The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Ftp code in Perl Raynon Shell Programming and Scripting 21 09-11-2008 03:44 AM
PERL Code talashil Shell Programming and Scripting 2 06-06-2008 01:13 AM
Hiding perl-cgi code sudhir_onweb Shell Programming and Scripting 4 03-21-2007 10:37 PM
perl code help circleW UNIX for Dummies Questions & Answers 1 11-09-2004 05:28 PM
Perl: export variable to shell oldtrash Shell Programming and Scripting 2 09-11-2003 10:23 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-12-2008
send2sridhar send2sridhar is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 4
Refrence Shell variable in Perl code.



I have 2 files a & b
Contents of a are:-
--------------------------
This is a Good Boy
This is a Good Boy
This is a Very Good Boy
This is a Good Boy
This is a Good Boy
---------------------------

The contents of b are
-------------------
This is Testing Beta
--------------

I have a piece of code :-

i=`cat a|grep "Very Good"`
echo $i
perl -pi -e 's/^(This is a Very Good Boy)/$1."\n".`cat b`/e' a

Now the above piece of code works perfectly well. That is String 'This is Testing Beta', needs to be added just under the string ''This is a Very Good Boy', followed by the remaining lines of code from file a. However, I want to refrence Shell variable 'i' instead of hard coding the string 'This is a Very Good Boy'? Please help urgent.

Any other forms of help are also welcome, I mean if we could do the above effort with just Shell,awk,sed or combination of all 3. All your help is highly appreciated.

Regards
Sri


The Final Output Should look something like this. I mean the final contents of File a
----------------------
This is a Good Boy
This is a Good Boy
This is a Very Good Boy
This is Testing Beta

This is a Good Boy
This is a Good Boy
-------------------------
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0