yael
yael

Reputation: 2913

perl + export param in to perl syntax in shell script

I have the following script that replace a param to b param and match only the c parameter in line how to change the perl syntax: if /$c/ in order to export c param to the follwoing perl syntax

#!/bin/bash
export a='@d&' 
export b='new text' 
export c='bla bla'
echo $LINE |  perl -pe 'next if /^#/; s/(^|\s)\Q$ENV{a}\E(\s|$)/$1$ENV{b}$2/ if /$c/' 

example of line

parameter=@d&

when c is the parameter

Upvotes: 0

Views: 181

Answers (1)

dsm
dsm

Reputation: 10403

what you need is

if /$ENV{c}/

And please format your code properly

Upvotes: 2

Related Questions