3

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.

1 Answers1

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
kukulo
  • 2,015