I'm using terminal on OSX along with the find command to find *.txt files and then rm them with the current time/date stamp. All my files which find locates consists of filename_day_month_year_hour. What I would like to do is to do is replace the filename part and add the current time/date stamp?
1 Answer
It's been a while since I've used Bash, but it would be something like this:
for $i in `find /where *.txt` mv $i `date`.txt;
-
This will not work. First of all, if
find
outputs any file with a space in its name, this won't be passed to$i
properly. Also, since$(date)
expands toWed Jan 9 10:34:13 CET 2013
, for example, themv
wouldn't see the correct argument either—it needs to be quoted. Finally, this isn't even the correct syntax for Bash. Afterfor
, there should be a; do mv …; done
.– slhckJan 9, 2013 at 9:34 -
Cool beans. I said it was a bit since I used bash anyway but I knew it was a one liner. Kudoz– JayJan 9, 2013 at 9:36