text file search yyyy/mm/dd and replace with yyyy-mm-dd
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a file with many tags in the form of yyyy/mm/dd
as in the line below and want to replace the /
with -
to give yyyy-mm-dd
at all instances in the one file.
e.g.
from this: <tag k='start_date' v='2011/01/01' />
to this: <tag k='start_date' v='2011-01-01' />
I'm on Mac 10.11.6
text-processing replace
add a comment |Â
up vote
0
down vote
favorite
I have a file with many tags in the form of yyyy/mm/dd
as in the line below and want to replace the /
with -
to give yyyy-mm-dd
at all instances in the one file.
e.g.
from this: <tag k='start_date' v='2011/01/01' />
to this: <tag k='start_date' v='2011-01-01' />
I'm on Mac 10.11.6
text-processing replace
are you able to install xml/html parsers?
â RomanPerekhrest
Apr 20 at 6:35
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a file with many tags in the form of yyyy/mm/dd
as in the line below and want to replace the /
with -
to give yyyy-mm-dd
at all instances in the one file.
e.g.
from this: <tag k='start_date' v='2011/01/01' />
to this: <tag k='start_date' v='2011-01-01' />
I'm on Mac 10.11.6
text-processing replace
I have a file with many tags in the form of yyyy/mm/dd
as in the line below and want to replace the /
with -
to give yyyy-mm-dd
at all instances in the one file.
e.g.
from this: <tag k='start_date' v='2011/01/01' />
to this: <tag k='start_date' v='2011-01-01' />
I'm on Mac 10.11.6
text-processing replace
edited Apr 20 at 5:30
ñÃÂsýù÷
14.8k82462
14.8k82462
asked Apr 20 at 4:41
Nev
1
1
are you able to install xml/html parsers?
â RomanPerekhrest
Apr 20 at 6:35
add a comment |Â
are you able to install xml/html parsers?
â RomanPerekhrest
Apr 20 at 6:35
are you able to install xml/html parsers?
â RomanPerekhrest
Apr 20 at 6:35
are you able to install xml/html parsers?
â RomanPerekhrest
Apr 20 at 6:35
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
You can use sed
for that
$ sed -E 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
Give a try.
To edit the file in place, with macOS or FreeBSD, add a -i ''
option. Most of other sed
implementations need -i
alone for that (-i.back
would work for both and save the original with a .back
extension). On systems where sed
doesn't support in-place editing, you can use perl -pi -e
in place of sed -E
(which inspired those sed -i
).
add a comment |Â
up vote
-1
down vote
Sorry, no it did not work.
The text is unchanged
But this worked fine ...
perl -pi -e 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
You can use sed
for that
$ sed -E 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
Give a try.
To edit the file in place, with macOS or FreeBSD, add a -i ''
option. Most of other sed
implementations need -i
alone for that (-i.back
would work for both and save the original with a .back
extension). On systems where sed
doesn't support in-place editing, you can use perl -pi -e
in place of sed -E
(which inspired those sed -i
).
add a comment |Â
up vote
2
down vote
You can use sed
for that
$ sed -E 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
Give a try.
To edit the file in place, with macOS or FreeBSD, add a -i ''
option. Most of other sed
implementations need -i
alone for that (-i.back
would work for both and save the original with a .back
extension). On systems where sed
doesn't support in-place editing, you can use perl -pi -e
in place of sed -E
(which inspired those sed -i
).
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You can use sed
for that
$ sed -E 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
Give a try.
To edit the file in place, with macOS or FreeBSD, add a -i ''
option. Most of other sed
implementations need -i
alone for that (-i.back
would work for both and save the original with a .back
extension). On systems where sed
doesn't support in-place editing, you can use perl -pi -e
in place of sed -E
(which inspired those sed -i
).
You can use sed
for that
$ sed -E 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
Give a try.
To edit the file in place, with macOS or FreeBSD, add a -i ''
option. Most of other sed
implementations need -i
alone for that (-i.back
would work for both and save the original with a .back
extension). On systems where sed
doesn't support in-place editing, you can use perl -pi -e
in place of sed -E
(which inspired those sed -i
).
edited Apr 20 at 13:04
Stéphane Chazelas
279k53514846
279k53514846
answered Apr 20 at 4:48
tachomi
3,39431134
3,39431134
add a comment |Â
add a comment |Â
up vote
-1
down vote
Sorry, no it did not work.
The text is unchanged
But this worked fine ...
perl -pi -e 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
add a comment |Â
up vote
-1
down vote
Sorry, no it did not work.
The text is unchanged
But this worked fine ...
perl -pi -e 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
Sorry, no it did not work.
The text is unchanged
But this worked fine ...
perl -pi -e 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
Sorry, no it did not work.
The text is unchanged
But this worked fine ...
perl -pi -e 's|([0-9]4)/([0-9]2)/([0-9]2)|1-2-3|g' file
edited Apr 20 at 7:23
Romeo Ninov
4,35811625
4,35811625
answered Apr 20 at 5:23
nwastra
11
11
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f438867%2ftext-file-search-yyyy-mm-dd-and-replace-with-yyyy-mm-dd%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
are you able to install xml/html parsers?
â RomanPerekhrest
Apr 20 at 6:35