The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Processes by User's actual names kartikkumar84@g Shell Programming and Scripting 1 05-22-2008 08:52 AM
Processes by Actual names kartikkumar84@g UNIX for Dummies Questions & Answers 2 05-13-2008 03:03 PM
actual filesystem size during backup shorty UNIX for Dummies Questions & Answers 1 02-20-2008 03:05 PM
Need actual bootpd for solaris johnnypark SUN Solaris 0 04-28-2005 07:51 AM
Actual Memory Usage gelbvonn UNIX for Dummies Questions & Answers 5 05-11-2004 07:13 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 09-19-2005
Registered User
 

Join Date: Mar 2005
Posts: 48
How can I match . (actual dot) using sed?

Hi All,
How can I match . (actual dot) using sed? Please help.

Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 09-19-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
You need to escape it with a \

Look at this.

Code:
sh-2.05b$ cat jing.txt
test
.
test.match
Code:
sh-2.05b$ sed -n -e '/\./p' jing.txt
.
test.match
Reply With Quote
  #3  
Old 09-19-2005
Registered User
 

Join Date: Mar 2005
Posts: 48
Thanks vino.

But this doesn't work. I am looking for /./* (one or more of /./ and replace with a single /./

I tried dereferencing . and /
it doen't work. Please help.

Thanks
Reply With Quote
  #4  
Old 09-19-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
This is going to be a confusing regex.

Code:
sed -e 's#\/\.\/\{1,\}#\/\.\/#g'
vino
Reply With Quote
  #5  
Old 09-19-2005
Registered User
 

Join Date: Mar 2005
Posts: 48
Please see below:

cat 1 gives:

/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./

sed -e 's#\.\{1,\}#\.#g' 1 > 2

now see cat 2

/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./

It is not working.
Reply With Quote
  #6  
Old 09-19-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Yes the previous solution will not work.

But this should work

Code:
sh-2.05b$ cat jing.txt 
test
/./
test/.//.//./match
sh-2.05b$ sed  -e 's#\(\/\.\/\)*#\1#g' jing.txt 
test
/./
test/./match
vino
Reply With Quote
  #7  
Old 09-19-2005
Registered User
 

Join Date: Mar 2005
Posts: 48
cat 1
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./

sed -e 's#\(\/\.\/\)*#\1#g' 1 > 2

cat 2
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./

It is not working. Is there is special reason why this doesn't work?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0