-1

First let me apologize for asking a question that:

  • Has some examples, though I find them confusing
  • Has a man page, also find confusing

Problem:

I would like to replace text in a $STRING within bash for a script I am writing. I chose to combine date/time to allow for easier end user integration.

STARTTIME="2015-03-17/11:30:00"
sed "Unknown"

Attempted Solution:

sed '/s// /' "$STARTTIME"

Desired result is to remove the "/" and end up with 2015-03-17 11:30:00 to then be passed to a command.

Thank you for any assistance.

ImNotLeet
  • 381
  • 5
  • 19

1 Answers1

1

If you're using bash, I would suggest that you used built-in string manipulation:

$ s='2015-03-17/11:30:00'
$ echo "${s/\// }"
2015-03-17 11:30:00

The syntax inside the braces means "replace the first occurrence of a forward slash (which needs escaping) with a space".

Tom Fenech
  • 72,334
  • 12
  • 107
  • 141