Quantcast
Channel: Linux Commands – BinaryTides
Viewing all articles
Browse latest Browse all 9

10 practical examples of Touch command on Linux

0
0
Linux Touch command
The touch command can be used to modify the access/modification timestamps of files. It is more often used to actually just create an empty file quickly.
This post shows some very simple and quick examples of using the touch command to modify timestamps or create files.
1. Create a blank file
To simply create a blank file with touch command, use the syntax below.
$ touch abc.txt
If the file already exists, its access time will be updated.
2. Create multiple files with touch
To create multiple files, specify their names together separated by a space.
$ touch abc.txt cde.txt xyz.txt
3. Create lots and lots of files
If for some reason you wish to create lots of files, then commands like these would be very helpful
# Create files with names A to Z
$ touch {A..Z}

# Create files with names 1 to 20
$ touch {1..20}

# Create files with extension
$ touch {1..1000}.txt

# Create 10K files
$ touch {1..10}{1..1000}
And then use the ls command to see what all has been created.
4. Avoid creating new files
If you want to just update the access time of existing file, without creating it, use the '-c' option. If the file exists, touch will update the access time, else will do nothing
$ touch -c hello.txt
5. Change...

Read full post here
10 practical examples of Touch command on Linux


Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images