Re: making unique file names

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Brian Cluff
Date:  
To: Main PLUG discussion list
Subject: Re: making unique file names
On 04/06/2015 09:10 PM, Michael Havens wrote:
> I am writing someone a letter. He has script that runs apt-get
> update/grade in one swoop. Something happened once and he needed to see
> what files had upgraded but because nothing print to screen he had no
> idea which files did. Could someone tell me if I am telling it
> correctly? In the unfinished paragraph I am unsure how to finish it.
> What I want to do is prepend 'file' with the date. How is it done?
> Here is the letter:


This will prepend the file with a date that is the year, month, day,
hour, minute , second all run together.
sudo apt-get update >$(date +"%Y%m%d%H%M%S")-file

But you might be able to get what you want by looking at the dpkg log in
/var/log/dpkg.log

If you want to continue to redirect your apt output to a file may I
suggest instead of just directly redirection everything to a file that
you instead send it through tee so that you can both see it and get your
file.

So instead of using > write your file do this:
sudo apt-get update | tee $(date +"%Y%m%d%H%M%S")-file

and instead of using >> to append to a file do this:
sudo apt-get update | tee -a $(date +"%Y%m%d%H%M%S")-file

I hope that helps.

Brian Cluff

> you know wiz, you might want to make your script print the output of
> update/upgrade to a file in case something like this happens again and
> you need to see what it did. You do this by typing:
>
>
>     sudo apt-get update > file

>
>     sudo apt-get upgrade >> file

>
>
> If you want it to print any errors that may have scrolled by to the file
> you'll have to pre-pend the carrots with '&2' to make it look like this:
>
>
>     sudo apt-get update &2> file

>
> and
>
>     sudo apt-get upgrade &2>> file

>
>
> I'm pretty sure that is how it is done at least. I wouldn't worry about
> making 'file' unique for each time you run it as you'll never look at it
> unless there is a problem. If you really want to do that
>
> :-)~MIKE~(-:
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>


---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss