![]() |
bash - find newest file in a directory
Hello everyone,
Basically, I am trying to locate and copy the newest .json bookmark backup in my .mozilla/firefox/w987sdg9.default/bookmarkbackups directory. I tried this Code:
ls -t ~/.mozilla/firefox/b1ahb1ah.default/bookmarkbackups/ | head -1So, it seems to me that find might work well here, and I know how to find based on absolute dates, but not relative. Is there a "good" way to do this? Thanks! |
This is interesting, and maybe hackish, but try this:
Code:
Plus, you can use the find commands -exec option to run `cp` and do the copying for you, something like: Code:
find /home/sasha -type f -iname $(ls -t ~/.mozilla/firefox/b1ahb1ah.Default/bookmarkbackups/ | head -1) -exec cp {} /destination/path \;Sasha |
Or, easier:
Code:
find ~ -type f -iname $(ls -t ~/.mozilla/firefox/wu0fj5gp.Default/bookmarkbackups | head -1) |
| All times are GMT -5. The time now is 04:11 AM. |