- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Variable probleme
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2009 10:39 AM
06-03-2009 10:39 AM
Here my call
find /su01/opus/html/*.html -type f -exec perl -i -pe 's|\Q’$ENVSOURCE’\E|’$ENVDEST’|g' {} \;
The problem is that $ENVSOURCE and $ENVDEST are never evaluated. Why ?
Bests Regards
Den
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2009 10:44 AM
06-03-2009 10:44 AM
Re: Variable probleme
I have tried $($ENVSOURCE) without success
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2009 10:59 AM
06-03-2009 10:59 AM
Re: Variable probleme
find /su01/opus/html/*.html -type f -exec perl -i -pe 's|\Qâ $ENVSOURCEâ \E|â $ENVDESTâ |g' {} \;
Works perfectly in a command line mode.
The problem is when I have trued to put this command in a ksh script !
Bests regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2009 11:02 AM
06-03-2009 11:02 AM
Re: Variable probleme
my system, so I can't tell what they really
are, but inside apostrophes, variables are
not evaluated. For example:
alp$ E='a b c'
alp$ echo ${E}
a b c
alp$ echo "${E}"
a b c
alp$ echo '${E}'
${E}
"man sh"? Buy a book?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2009 11:06 AM
06-03-2009 11:06 AM
Re: Variable probleme
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2009 11:06 AM
06-03-2009 11:06 AM
Re: Variable probleme
Probably, you should write a perl script and call the script from the find command. I don't know much about perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2009 01:38 PM
06-03-2009 01:38 PM
SolutionThe $ENVSOURCE and $ENVDEST are Perl's variables, not the shell's. All you need do is this:
# export ENVSOURCE=oldthing
# export ENVDEST=newthing
# perl -i.old -pe 'BEGIN{$ENVSOURCE=$ENV{ENVSOURCE};$ENVDEST=$ENV{ENVDEST};};s|\Q.$ENVSOURCE.\E|.$ENVDEST.|g' file
Thus we export to the environment in which Perl will run and then tell Perl to use the exported environmental variables.
Obviously you can couple this with your shell find() as you wrote. You could also use Perl's 'File::Find' module directory.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2009 04:18 AM
09-15-2009 04:18 AM
Re: Variable probleme
Thanks Guys