1

I have searched for a similar question here, but found nothing related.

In Linux, the dot (.) refers to the directory itself. The touch command creates a file, if it does not exist.

But what does touch . (dot as argument) do?

I have checked the GNU touch documentation and the LINFO information about dot, but found nothing related.

I have tried this command in my Fedora and it seems that nothing is changed.

4
  • atime might have changed Oct 29, 2018 at 2:33
  • @神秘德里克, thank. That clears things. Now I see it in ls output. Now I consider voting this question for deletion. But maybe there is another thing apart from that that touch does?
    – Silv
    Oct 29, 2018 at 2:39
  • You can strace it. I believe it doesn't do too much work Oct 29, 2018 at 2:41
  • Hm, I did not know about strace tool. Thanks.
    – Silv
    Oct 29, 2018 at 2:43

3 Answers 3

2

From the GNU touch documentation:

touch changes the access and/or modification timestamps of the specified files.

So, if the file exists, then touch modifies it's timestamps. We can check this:

$ stat .
File: '.'
Size: 40              Blocks: 0          IO Block: 4096   directory
Device: 11h/17d Inode: 2338759     Links: 2
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ chronos)   Gid: ( 1000/ chronos)
Context: u:object_r:tmpfs:s0
Access: 2018-10-29 08:06:16.918056344 +0530
Modify: 2018-10-29 08:06:15.484056316 +0530
Change: 2018-10-29 08:06:15.484056316 +0530
Birth: -

Now we run touch . and then:

$ stat .
File: '.'
Size: 40              Blocks: 0          IO Block: 4096   directory
Device: 11h/17d Inode: 2338759     Links: 2
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ chronos)   Gid: ( 1000/ chronos)
Context: u:object_r:tmpfs:s0
Access: 2018-10-29 08:06:29.131056579 +0530
Modify: 2018-10-29 08:06:29.131056579 +0530
Change: 2018-10-29 08:06:29.131056579 +0530
Birth: -

Note how the Access:, Modify: and Change: fields have changed.

1
  • Thanks for listings and the stat utility, I did not know about it. :)
    – Silv
    Oct 29, 2018 at 2:52
1

The short description in man touch says

change file timestamps

which is what it does in this case - it updates the modified timestamp of the current directory to the current time.

1
  • Thanks. Obvious. That is a kind of information that I always miss when reading about touch (because I do not know what I would like to change the time for).
    – Silv
    Oct 29, 2018 at 2:44
-3

touch [dot] create hidden file with this name (.) you can check attached image enter image description here

1
  • 2
    This is just not true. . exists in every directory, as a reference to itself.
    – l0b0
    Oct 29, 2018 at 2:43

You must log in to answer this question.

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