Keith Bainbridge
2024-07-23 07:10:01 UTC
Good afternoon All
For reference, today is Tue ***@15:41:47 205.2024 AEST
This is part of my command prompt, generated by
PS1='\n \u@\h \n\n $(date +"%a %d%b%Y@%H:%M:%S %j.%Y %Z") \n :\w $> '
My calculation is that today is day 205
When I run this function
mkcd ()
{
mkdir -p $1
cd $1
}
in the form :~ $> mkcd
/mnt/data/keith/Documents/$YEAR/$MTH$YEAR/$DOYR.$YEAR/
I am transferred to
/mnt/data/keith/Documents/2024/Jul2024/196.2024 $> ie $DOYR is
using the wrong day number
So I cd to my home and run the commands separately, in the form
:~ $> mkdir -p /mnt/data/keith/Documents/$YEAR/$MTH$YEAR/$DOYR.$YEAR/
***@lenv0
Tue ***@15:38:24 205.2024 AEST
:~ $> cd /mnt/data/keith/Documents/$YEAR/$MTH$YEAR/$DOYR.$YEAR/
and land in /mnt/data/keith/Documents/2024/Jul2024/196.2024
ls -lah /mnt/data/keith/Documents/2024/Jul2024
total 104K
drwxr-xr-x 8 keith keith 4.0K Jul 22 13:33 .
drwxr-xr-x 30 keith keith 4.0K Jul 13 11:53 ..
sdrwxr-xr-x 2 keith keith 4.0K Jul 22 13:33 196.2024
drwxr-xr-x 2 keith keith 4.0K Jul 13 11:53 day189.2024
drwxr-xr-x 2 keith keith 4.0K Jul 13 11:53 day192.2024
drwxr-xr-x 2 keith keith 4.0K Jul 13 11:53 day193.2024
drwxr-xr-x 2 keith keith 4.0K Jul 13 11:53 day194.2024
drwxr-xr-x 2 keith keith 4.0K Jul 22 13:21 day196.2024
shows that directory 196.2024 was created yesterday. (My original
format for the new dir was $MTH$YEAR/day$DOYR.$YEAR/ I took the 'day'
out in case that was creating a problem that I haven't seen before.
OK then, I have 2 questions:
Why is the env var $DOYR not updating when I use it at the command
prompt AND for that matter in a script - clearly the system is or I'd be
getting the wrong day # at my command prompt?
Why am I not getting a warning that the dir already exists?
I want to run the script as a cron job, to keep a daily copy of a few
files - mainly to prove that I can do it.
Thanks for any suggestions
By the bye, I expanded the date format for my command prompt as part of
the discussion I started a few weeks back about the date the sender sent
mail showing in a reply.
--
All the best
Keith Bainbridge
***@gmail.com
***@gmail.com
+61 (0)447 667 468
UTC + 10:00
For reference, today is Tue ***@15:41:47 205.2024 AEST
This is part of my command prompt, generated by
PS1='\n \u@\h \n\n $(date +"%a %d%b%Y@%H:%M:%S %j.%Y %Z") \n :\w $> '
My calculation is that today is day 205
When I run this function
mkcd ()
{
mkdir -p $1
cd $1
}
in the form :~ $> mkcd
/mnt/data/keith/Documents/$YEAR/$MTH$YEAR/$DOYR.$YEAR/
I am transferred to
/mnt/data/keith/Documents/2024/Jul2024/196.2024 $> ie $DOYR is
using the wrong day number
So I cd to my home and run the commands separately, in the form
:~ $> mkdir -p /mnt/data/keith/Documents/$YEAR/$MTH$YEAR/$DOYR.$YEAR/
***@lenv0
Tue ***@15:38:24 205.2024 AEST
:~ $> cd /mnt/data/keith/Documents/$YEAR/$MTH$YEAR/$DOYR.$YEAR/
and land in /mnt/data/keith/Documents/2024/Jul2024/196.2024
ls -lah /mnt/data/keith/Documents/2024/Jul2024
total 104K
drwxr-xr-x 8 keith keith 4.0K Jul 22 13:33 .
drwxr-xr-x 30 keith keith 4.0K Jul 13 11:53 ..
sdrwxr-xr-x 2 keith keith 4.0K Jul 22 13:33 196.2024
drwxr-xr-x 2 keith keith 4.0K Jul 13 11:53 day189.2024
drwxr-xr-x 2 keith keith 4.0K Jul 13 11:53 day192.2024
drwxr-xr-x 2 keith keith 4.0K Jul 13 11:53 day193.2024
drwxr-xr-x 2 keith keith 4.0K Jul 13 11:53 day194.2024
drwxr-xr-x 2 keith keith 4.0K Jul 22 13:21 day196.2024
shows that directory 196.2024 was created yesterday. (My original
format for the new dir was $MTH$YEAR/day$DOYR.$YEAR/ I took the 'day'
out in case that was creating a problem that I haven't seen before.
OK then, I have 2 questions:
Why is the env var $DOYR not updating when I use it at the command
prompt AND for that matter in a script - clearly the system is or I'd be
getting the wrong day # at my command prompt?
Why am I not getting a warning that the dir already exists?
I want to run the script as a cron job, to keep a daily copy of a few
files - mainly to prove that I can do it.
Thanks for any suggestions
By the bye, I expanded the date format for my command prompt as part of
the discussion I started a few weeks back about the date the sender sent
mail showing in a reply.
--
All the best
Keith Bainbridge
***@gmail.com
***@gmail.com
+61 (0)447 667 468
UTC + 10:00