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 !!

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 11-11-2005
Aceform Aceform is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 22
Help on sed please

Hi,

I need get rid of all the dots and : in the below line 2005.11.11 09:37:28. I have tried the below command

echo 2005.11.11 09:37:28 | sed -e 's/.//' -e 's/.//' -e 's/://' -e 's/://'

No luck.

Any help is very much appreciated.
  #2 (permalink)  
Old 11-11-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131

Code:
echo '2005.11.11 09:37:28' | sed 's/[.:]//g'

  #3 (permalink)  
Old 11-11-2005
Aceform Aceform is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 22
Many thanks for your speedy response. Very much appreciated.
  #4 (permalink)  
Old 11-14-2005
Aceform Aceform is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 22
Hi,

Can you please tell me, if there is anyway I can replace first n occurances of the character.

For example: If the input is like below

2005.11.11 09:25:47 5.0 5.75

The output I need is:

20051111,092547,5.0,5.75

Many thanks,

I'm a VMS guy myself, new to sed/awk. Just getting hang of things. So any help you guys could offer is very much appreciate.
  #5 (permalink)  
Old 11-14-2005
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,960
this is an round abt way
and surely there are better ways than this

echo "2005.11.11 09:25:47 5.0 5.75" | sed -e 's/://g;s/ /,/g;s/\.//1;s/\.//1'
  #6 (permalink)  
Old 11-14-2005
Aceform Aceform is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 22
Great. Many thanks for that. One finaly question on this,

how do I replace single quote

echo "2005.11.11 09:25:47 5.0 5.75 'ABCD' " | sed -e 's/://g;s/ /,/g;s/\.//1;s/\.//1'


Output should be 20051111,092547,5.0,5.75,ABCD

I tried below, but not able to replace the single quote


$echo "2005.11.11 09:25:47 5.0 5.75 'ABCD' " | sed -e 's/://g;s/ /,/g;s/\.//1;s/\.//1;s/\'//g'
> '
sed: command garbled: s/://g;s/ /,/g;s/\.//1;s/\.//1;s/\//g


$ echo "2005.11.11 09:25:47 5.0 5.75 'ABCD' " | sed -e 's/://g;s//,/g;s/\.//1;s/\.//1;s/''//g'
20051111,092547,50,575,'ABCD',

$ echo "2005.11.11 09:25:47 5.0 5.75 'ABCD' " | sed -e 's/://g;s/ /,/g;s/\.//1;s/\.//1;s/'''//g'
> '
20051111,092547,50,575,'ABCD',

Please help me out guys
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 07:54 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