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 12:52 PM
Processes by Actual names kartikkumar84@g UNIX for Dummies Questions & Answers 2 05-13-2008 07:03 PM
actual filesystem size during backup shorty UNIX for Dummies Questions & Answers 1 02-20-2008 06:05 PM
Need actual bootpd for solaris johnnypark SUN Solaris 0 04-28-2005 11:51 AM
Actual Memory Usage gelbvonn UNIX for Dummies Questions & Answers 5 05-11-2004 11:13 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-19-2005
jingi1234 jingi1234 is offline
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
  #2 (permalink)  
Old 09-19-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
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
  #3 (permalink)  
Old 09-19-2005
jingi1234 jingi1234 is offline
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
  #4 (permalink)  
Old 09-19-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

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

Code:
sed -e 's#\/\.\/\{1,\}#\/\.\/#g'
vino
  #5 (permalink)  
Old 09-19-2005
jingi1234 jingi1234 is offline
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.
  #6 (permalink)  
Old 09-19-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0