Convert all pdf file to tar file if the size is between 10KB - 20KB

Posted by Rajnilari2015 under Others category on | Points: 40 | Views : 1545
The tar command stores and extract files from an archive file known as a tarfile.

Syntax :
tar <operation> [options]

A full list of tar options and more about the same can be refer from here ( ).

In our case, the scenario is to Convert a pdf file to tar file if the size equals 1MB

So let us issue the below command from the Ubuntu terminal

tar rvf destinaiton.tar $(find /Desktop/MyFolders -name "*.pdf" -size +10k -size -20k)

The options

r => append,
v => verbose,
f => file

"destinaiton.tar" is the final tar file that will be generated

The find command plays an important role here.It is used to search and locate list of files and directories based on conditions we specify for files that match the arguments. For more information please refer ( ).

Now find /Desktop/MyFolders -name "*.pdf" -size +10k -size -20k indicates to find all the ".pdf" files under /Desktop/MyFolders location whose size is between 10KB - 20KB

Hope this helps

Comments or Responses

Login to post response