Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from May 19 '12 at 1:25

This question came from our site for professional and enthusiast programmers.

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;
share|improve this answer
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 '13 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 '13 at 9:36

You must log in to answer this question.

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