Change String to Date with using date -d
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I need to change a date String from format YYYYMMDD to date YYYY-MM-DD without using date -d command. The only option I found is string manipulations.
shell-script date
add a comment |Â
up vote
0
down vote
favorite
I need to change a date String from format YYYYMMDD to date YYYY-MM-DD without using date -d command. The only option I found is string manipulations.
shell-script date
How many tools can you name that perform text manipulation?âÂÂIf none, please go and do some basic research.âÂÂOtherwise, tell us what youâÂÂve tried.âÂÂ⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠â¦â P.S.â¯Technically, you have not asked a question.
â G-Man
Apr 2 at 15:58
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I need to change a date String from format YYYYMMDD to date YYYY-MM-DD without using date -d command. The only option I found is string manipulations.
shell-script date
I need to change a date String from format YYYYMMDD to date YYYY-MM-DD without using date -d command. The only option I found is string manipulations.
shell-script date
asked Apr 2 at 15:33
Hassam
63
63
How many tools can you name that perform text manipulation?âÂÂIf none, please go and do some basic research.âÂÂOtherwise, tell us what youâÂÂve tried.âÂÂ⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠â¦â P.S.â¯Technically, you have not asked a question.
â G-Man
Apr 2 at 15:58
add a comment |Â
How many tools can you name that perform text manipulation?âÂÂIf none, please go and do some basic research.âÂÂOtherwise, tell us what youâÂÂve tried.âÂÂ⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠â¦â P.S.â¯Technically, you have not asked a question.
â G-Man
Apr 2 at 15:58
How many tools can you name that perform text manipulation?âÂÂIf none, please go and do some basic research.âÂÂOtherwise, tell us what youâÂÂve tried.âÂÂ⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠â¦â P.S.â¯Technically, you have not asked a question.
â G-Man
Apr 2 at 15:58
How many tools can you name that perform text manipulation?âÂÂIf none, please go and do some basic research.âÂÂOtherwise, tell us what youâÂÂve tried.âÂÂ⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠â¦â P.S.â¯Technically, you have not asked a question.
â G-Man
Apr 2 at 15:58
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
What about using bash parameter expansion?
$ var=20180402
$ echo "$var::4-$var:4:2-$var:6"
2018-04-02
Spot of code golf: the last term could just be '$var:6'
â bu5hman
Apr 2 at 17:10
Further golf : the first term could be just$var::4
â steve
Apr 2 at 18:33
Thanks didn't think about either. I did consider using$var: -2
for the last one but didn't want to lead to confusion.
â Jesse_b
Apr 2 at 19:17
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
What about using bash parameter expansion?
$ var=20180402
$ echo "$var::4-$var:4:2-$var:6"
2018-04-02
Spot of code golf: the last term could just be '$var:6'
â bu5hman
Apr 2 at 17:10
Further golf : the first term could be just$var::4
â steve
Apr 2 at 18:33
Thanks didn't think about either. I did consider using$var: -2
for the last one but didn't want to lead to confusion.
â Jesse_b
Apr 2 at 19:17
add a comment |Â
up vote
3
down vote
accepted
What about using bash parameter expansion?
$ var=20180402
$ echo "$var::4-$var:4:2-$var:6"
2018-04-02
Spot of code golf: the last term could just be '$var:6'
â bu5hman
Apr 2 at 17:10
Further golf : the first term could be just$var::4
â steve
Apr 2 at 18:33
Thanks didn't think about either. I did consider using$var: -2
for the last one but didn't want to lead to confusion.
â Jesse_b
Apr 2 at 19:17
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
What about using bash parameter expansion?
$ var=20180402
$ echo "$var::4-$var:4:2-$var:6"
2018-04-02
What about using bash parameter expansion?
$ var=20180402
$ echo "$var::4-$var:4:2-$var:6"
2018-04-02
edited Apr 2 at 19:16
answered Apr 2 at 15:36
Jesse_b
10.4k22658
10.4k22658
Spot of code golf: the last term could just be '$var:6'
â bu5hman
Apr 2 at 17:10
Further golf : the first term could be just$var::4
â steve
Apr 2 at 18:33
Thanks didn't think about either. I did consider using$var: -2
for the last one but didn't want to lead to confusion.
â Jesse_b
Apr 2 at 19:17
add a comment |Â
Spot of code golf: the last term could just be '$var:6'
â bu5hman
Apr 2 at 17:10
Further golf : the first term could be just$var::4
â steve
Apr 2 at 18:33
Thanks didn't think about either. I did consider using$var: -2
for the last one but didn't want to lead to confusion.
â Jesse_b
Apr 2 at 19:17
Spot of code golf: the last term could just be '$var:6'
â bu5hman
Apr 2 at 17:10
Spot of code golf: the last term could just be '$var:6'
â bu5hman
Apr 2 at 17:10
Further golf : the first term could be just
$var::4
â steve
Apr 2 at 18:33
Further golf : the first term could be just
$var::4
â steve
Apr 2 at 18:33
Thanks didn't think about either. I did consider using
$var: -2
for the last one but didn't want to lead to confusion.â Jesse_b
Apr 2 at 19:17
Thanks didn't think about either. I did consider using
$var: -2
for the last one but didn't want to lead to confusion.â Jesse_b
Apr 2 at 19:17
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%2f435069%2fchange-string-to-date-with-using-date-d%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
How many tools can you name that perform text manipulation?âÂÂIf none, please go and do some basic research.âÂÂOtherwise, tell us what youâÂÂve tried.âÂÂ⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠⦠â¦â P.S.â¯Technically, you have not asked a question.
â G-Man
Apr 2 at 15:58