Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 1
    ... and it could be done in other ways, e.g. perl. Generally forget sed for arithmetics. Commented Sep 28, 2020 at 9:08
  • Thank you for this! I would need to append this data as a new column in an output CSV file, how could I do that in the command line format I mentioned after the $ sign? Commented Sep 28, 2020 at 13:32
  • @Phillip: for output redirection, just do ` > output-file` at the end f the one liner above. See edit. Commented Sep 28, 2020 at 13:51
  • 1
    @Cbhihe You can actually incorporate calculation of the "current year" into the awk call via the strftime() function: awk 'BEGIN{year=strftime("%Y"); FS="/"} ..... '. Commented Sep 28, 2020 at 15:21
  • 3
    I can't let the sed arithmetic comment go without mentioning unix.stackexchange.com/a/36959/117549 Commented Oct 2, 2020 at 0:26