DEV Community


Discussion on: Creating files with "touch"

ferricoxide profile image
Thomas H Jones II

touch is great when you want to find a file with a higher degree of time-fidelity than what the various -Xtime flags will get you. E.g., With find's mtime flag, I'm limited to "modified less than 24 hours ago". However, if I use touch in concert with one of find's Xnewer flags, I can reduce my search window to something much smaller. E.g., I could do something like:

touch -t $(date -d "2 mins ago" +%Y%m%d%H%M.%S) /tmp/.stamp
find . -newer /tmp/.stamp

Haven't had much need of this lately, but, was previously useful compiling something from source and didn't intimately know where it would have put all the files I needed to care about.