I would like to know every file which is +100Mb and hasn't been accessed in the last month, and I have written succesfully:
find / -size +100M -atime +30
And now I want to move those files to a folder called /big-not-used changing its name as: file_nameYYYYMMDD
where file_name is the orginal's file's name and YYYYMMDD is today's date, in year month day. For example film.mkv
goes to /big-not-used/film.mkv20161031
My sentence would be:
find / -size +100M -atime +30 -exec mv {} /big-not-used/... \;
But I don't know how to append today's date at the file's name.
I have found that date +%Y-%m-%d
outputs: 2016-10-31
which is useful.
Now the doubt is how to get this file's name?
Following:
https://stackoverflow.com/questions/5456120/how-to-only-get-file-name-with-linux-find
... -exec basename {} \;
Maybe?:
find / -size +100M -atime +30 -exec mv {} /big-not-used/$(basename {})$(date +%Y-%m-%d) \;
But it gives an error because basename is replying with the file's full path instead of its name which I would use:
${var##/*/}
to get the file's name, but the question is how do I insert what basename {}
replies into the var in the previous expresion!?.
Maybe?
$(${$(basename {})##/*/})
But is says sintactic error near the unexpected '}'...