1

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 1

0

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;
2
  • 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 to Wed Jan 9 10:34:13 CET 2013, for example, the mv wouldn't see the correct argument either—it needs to be quoted. Finally, this isn't even the correct syntax for Bash. After for, there should be a ; do mv …; done.
    – slhck
    Jan 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
    – Jay
    Jan 9, 2013 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .