PDA

View Full Version : [SOLVED] How do I set date so I know when a file was created



anden.d
July 23rd, 2011, 06:14 PM
Hi
I've been working with a script in ubuntu 11.04 it's basicly very simple but I got problem with a single line of code: cat /etc/passwd > passwd´date +%Y%m´
The results I expect should be a readable file something like this example: passwd201106
Do you know what I have done wrong or do you have a better solution?
I'm a more used to red hat 2.0 so i wounder if it's just a minor difference between two linux systems?:confused:

Bachstelze
July 23rd, 2011, 06:31 PM
You are using the wrong kind of "apostrophes":


firas@itsuki ~ % cat /etc/passwd > passwd`date +%Y%m`
firas@itsuki ~ % ls passwd*
passwd201107


You can also use $(), which is less confusing:


firas@itsuki ~ % rm passwd201107
firas@itsuki ~ % cat /etc/passwd > passwd$(date +%Y%m)
firas@itsuki ~ % ls passwd*
passwd201107

anden.d
July 23rd, 2011, 08:41 PM
Thank you Newbie mistake but i't would probably take me days to figur it out thanks once again!:D