Training, Open Source
computer languages


PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
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.


WELL HOUSE CONSULTANTS LTD.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho