Well House Consultants Ltd.
spacer spacer
Perl Programming - Perl, mod-perl, CGI, etc.
>> Link to main Perl resources
>> Link to forum archive home
>> Link to live forum

Just try to solveit, if you can solve

Posted by Pawan_Sangal (Pawan_Sangal), 18 July 2006
I'm facing a confusion with Pattern Matching operators in my BASH.
Suppose, I have

$cd /home/db
$ ls -l
lrwxrwxrwx 1 ef ef 27 Aug 19 2004 dtest -> /home/dbtest//
lrwxrwxrwx 1 ef ef 18 Jul 7 2004 pase -> /systemlink/pbase
lrwxrwxrwx 1 ef ef 21 Apr 26 2004 pdcnt -> /systemlink/pdcnt/
lrwxrwxrwx 1 ef ef 24 Jul 20 2005 phistry -> /pf_hist1/phistry//
lrwxrwxrwx 1 ef ef 20 Jul 20 2005 pdtion -> /systemlink/pdtion/
lrwxrwxrwx 1 ef ef 21 Aug 24 2004 w1 -> /systemlink/pdcnt/

$cd /systemlink
$ ls -l
lrwxrwxrwx 1 ef ef 19 Jun 20 16:00 dbac -> /pf_hm4/dbac/
lrwxrwxrwx 1 ef ef 16 Aug 16 2005 home -> /logs/home/
lrwxrwxrwx 1 ef ef 21 Jun 20 15:59 pdcnt -> /pf_c4/pdcnt/
lrwxrwxrwx 1 ro ro 23 Aug 30 2004 phistry -> /pf_ht1/phistry/
lrwxrwxrwx 1 ef ef 11 Jun 24 2005 pdtion -> pdcnt/

All are the links in the above listing you have seen.
================================================== ==
now if in my BASH window: I'm trying

DATAB="pdtion"

v0=`ls -l /home/db|grep " ${DATAB} ->"`
echo "$v0" #------what v0 will have. please tell?
tag=${v0##* /} #----- what is there in tag. please tell?
v0=`ls -l /systemlink|grep " ${tag} ->"`
echo "$v0" #------now what v0 will have. please tell?
================================================== ==

I have also seen the other pattern matching operators like:
${v0##* /}, ${v0#* /}, ${v0%%:*}, ${v0%/*}
All of these have different means with a particular kind of line or pattern.


According to the script, its working properly to what it was built for.
But,
According to my assumption, As I'm trying this in normal shell window and had no relation with the script. If I'm trying to do the same procedure as above like echo the values of (tag) and (v0) without disturbing the script, I'm not getting that valid output, what the script is getting while executing.

Anyone, who have the answers to these queries. Please mail me at :
pawan.sangal@interglobetechnologies.com, or
sangal_urgent@yahoo.com

I will be greatly thankful, if anybody can tell me the exact values of (tag) and (v0) as i have discussed above. If anybody have any hints please share, regarding greping of links.

Thanks & Regards,
Pawan Sangal




This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.
spacer

You can Add a comment or ranking to this page

WELL HOUSE CONSULTANTS LTD • 404, The Spa • Melksham, Wiltshire SN12 6QL • United Kingdom
PHONE: 01144 1225 708225 • FACSIMILE 01144 1225 793803 • EMAIL: info@wellho.net
You are currently on our United States site. Change your country.
Privacy and Copyright StatementTerms and Conditions
Updated Saturday, April 27th 2024 • © Well House Consultants, 2024

This is page http://www.wellho.net/forum/Perl-Programming/Just-try-to-solveit-if-you-can-solve.html