Skip to Content
Linux Shell Scripting Cookbook - Third Edition
book

Linux Shell Scripting Cookbook - Third Edition

by Clif Flynt, Sarath Lakshman, Shantanu Tushar
May 2017
Beginner
552 pages
28h 47m
English
Packt Publishing
Content preview from Linux Shell Scripting Cookbook - Third Edition

How to do it...

To generate blank files in bulk, follow these steps:

  1. Invoking the touch command with a non-existent filename creates an empty file:
        $ touch filename
  1. Generate bulk files with a different name pattern:
        for name in {1..100}.txt 
        do 
          touch $name 
        done 

In the preceding code, {1..100} will be expanded to a string 1, 2, 3, 4, 5, 6, 7...100. Instead of {1..100}.txt, we can use various shorthand patterns such as test{1..200}.c, test{a..z}.txt, and so on.

If a file already exists, the touch command changes all timestamps associated with the file to the current time. These options define a subset of timestamps to be modified:

  • touch -a: This modifies the access time
  • touch -m: This modifies the modification time

Instead of the current ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett

Publisher Resources

ISBN: 9781785881985