0

This question already has an answer here:

I found this helpful post on how to export command output to a file, e.g.

command > myfile.txt

But is there a way I can export to myfileXXX.txt, where XXX is the day of the week, e.g. Mon, Tue, Wed, etc., or even 1, 2, 3, etc., or is there something similar like calendar date of month.

marked as duplicate by Melebius, pLumo, d a i s y, heemayl command-line Sep 6 '18 at 12:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

This script should work:

#!/bin/bash

dt=$(date '+%d%m%Y %H%M%S')
DAY=$(date +"%u")
c=$DAY$dt
command > myfile"$c".txt

or this command:

command > myfile$(date +%a).txt
  • 2
    To get only the dayname, command > myfile$(date +%a).txt is sufficient. – PerlDuck Sep 6 '18 at 12:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.