Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change [digit][digit]:[digit][digit] to [digit][digit].[digit][digit] 2

Status
Not open for further replies.

blarneyme

MIS
Jun 22, 2009
160
US
Have a file with multiple fields with time in the format:
Code:
15:02

that I want in the format
Code:
15.02

No matter what I use with sed I'm not getting the desired change.

Code:
sed 's/\(\d{2}):\(\d{2})/\(\d{2})\.\(\d{2})/g' file > file1
sed 's/[0-9]:[0-9]/[0-9]\.[0-9]/g' file > file1
Neither of the above gives desired output. What am I missing?
 
Hi

blarneyme said:
What am I missing?
The escaping :
[tt]sed 's/\(\d[red]\[/red]{2[red]\[/red]}[red]\[/red]):\(\d[red]\[/red]{2[red]\[/red]}[red]\[/red])/???/g' file > file1[/tt]

The quantifier :
[tt]sed 's/[0-9][red]\{2\}[/red]:[0-9][red]\{2\}[/red]/???/g' file > file1[/tt]

The capturing :
[tt]sed 's/[red]\([/red][0-9]\{2\}[red]\)[/red]:[red]\([/red][0-9]\{2\}[red]\)[/red]/???/g' file > file1[/tt]

Reading the documentation :
[tt]sed 's/\([0-9]\{2\}\):\([0-9]\{2\}\)/[red]\1[/red].[red]\2[/red]/g' file > file1[/tt]

Searching Tek-Tips for a suitable forum :
Your question is off-topic.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top