Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
3 added 154 characters in body
source | link
  1. First the date tool is not part of the bash, it is an external tool.
  2. Bash itself can't do it without external commands.
  3. Doing this with external commands can't pass your single-line criterion.

Thus, you can't do it.

However, if you allow 2 lines, or you write a function for that, you can do it, as it was written in the comments.

Extension: you can do it with more recent bashes (>4.2), even as a single-line command, although it won't be the most simplest bash line you've ever wrote. Check the other answer.

  1. First the date tool is not part of the bash, it is an external tool.
  2. Bash itself can't do it without external commands.
  3. Doing this with external commands can't pass your single-line criterion.

Thus, you can't do it.

However, if you allow 2 lines, or you write a function for that, you can do it, as it was written in the comments.

  1. First the date tool is not part of the bash, it is an external tool.
  2. Bash itself can't do it without external commands.
  3. Doing this with external commands can't pass your single-line criterion.

Thus, you can't do it.

However, if you allow 2 lines, or you write a function for that, you can do it, as it was written in the comments.

Extension: you can do it with more recent bashes (>4.2), even as a single-line command, although it won't be the most simplest bash line you've ever wrote. Check the other answer.

2 added 1 character in body
source | link
  1. First the date tool is not part of the bash, it is an external tool.
  2. Bash itself can't do it without external commands.
  3. Doing this with external commands can't pass your single-line criteriacriterion.

Thus, you can't do it.

However, if you allow 2 lines, or you write a function for that, you can do it, as it was written in the comments.

  1. First the date tool is not part of the bash, it is an external tool.
  2. Bash itself can't do it without external commands.
  3. Doing this with external commands can't pass your single-line criteria.

Thus, you can't do it.

However, if you allow 2 lines, or you write a function for that, you can do it, as it was written in the comments.

  1. First the date tool is not part of the bash, it is an external tool.
  2. Bash itself can't do it without external commands.
  3. Doing this with external commands can't pass your single-line criterion.

Thus, you can't do it.

However, if you allow 2 lines, or you write a function for that, you can do it, as it was written in the comments.

1
source | link

  1. First the date tool is not part of the bash, it is an external tool.
  2. Bash itself can't do it without external commands.
  3. Doing this with external commands can't pass your single-line criteria.

Thus, you can't do it.

However, if you allow 2 lines, or you write a function for that, you can do it, as it was written in the comments.