5

can anybody give me a solution to enlarge all files of same extension by 264 bytes on entire hard disk? truncate -s +264 /*encrypted would enlarge all *.encrypted files by 264 bytes but only in one directory.

I want it to do the subfolders as well

1 Answer 1

6

Try this:

find /path/to/directory -type f -name "*.encrypted" -exec truncate -s +264 {} +

find will search in the /path/to/directory and all of its subdirectories for files with .encrypted extension and then run your desired truncate command over all of those found files.

If you want to search for the files in entire disk:

sudo find / -type f -name "*.encrypted" -exec truncate -s +264 {} +

If you are not sure about the names, don't run this one rather you should explicitly mention the directories (and its subdirectories) to search for, for example the following will find and execute the command over the only the files found in /home/user and /tmp directories (and their subdirectories):

find /home/user/ /tmp/ -type f -name "*.encrypted" -exec truncate -s +264 {} +

Note that you need to use sudo to search in the directories where you don't have required permission.

1
  • what does the trailing + at the end of the command do ?
    – Max L.
    Apr 6, 2018 at 16:03

You must log in to answer this question.

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