I have a list I want to change from a script. I want to move top entry to bottom so I get a rotating list each time the script is run. I also want to append date to the line that got moved to bottom. from this. The top folder will be used to store old backups too using rclone.
old1
old2
old3
to this
old2
old3
old1 date time
I found a code I tried to use, but it wont move the top entry, just copy it to bottom so I get an output like this
old1
old2
old3
old1 date time
old1 date time
The code I tried # Rotate the BACKUPLIST-file, deleting the top entry and adding a new entry at the bottom
OLDEST=$(head -1 $BACKUPLIST | sed 's/ .*//') # The oldest, extra backup-version
COUNT=$(cat $BACKUPLIST | wc -l) # Number of files in list
((COUNT=$COUNT-1))
tail -$COUNT $BACKUPLIST > $BACKUPLIST.tmp
echo $OLDEST $(date) >> $BACKUPLIST.tmp # Add a new line to the bottom, including today's date
sed 's/ .*//'
to remove an existing date from the first line, right? – Freddy Jul 25 '19 at 21:48