4

In source directory, I have multiple files which all has dot (.) to it.

So, when I move I can give like below

mv *.* /destination/

But my issue is I want to give timestamp to all the files in destination folder for identification.

pLumo
  • 26,947

2 Answers2

1

While pLumo's solution is technically OK, it may be a bit confusing. You can achieve the same goal with two separate commands, first touching the files to update the access time, followed by the move command:

touch *.*
mv *.* /destination/

The reason to do it in this particular order is to not update the access times of files that may already be located in the /destination/ folder.

It may be worth noting that the wildcard pattern *.* does not match hidden files, which are marked by a leading dot on Unix systems (use ls .* to list them). It's up to you to decide if that's what you want to achieve or not.

Murphy
  • 1,677
0

Use xargs to touch and mv:

printf '%s\0' *.*  | xargs -0 sh -c 'touch "$@" && mv "$@" /destination/' xargs-sh

This has also the benefit of preventing "too many arguments" error, as xargs takes care of that.

pLumo
  • 26,947