Processing math: 100%

Amazon Ads

Saturday, November 2, 2019

Some useful UBUNTU commands

Hi so in this post I am going to mention some useful commands,

1. To remove *.swp file in all subdirectories


Run the following command


shopt -s globstar

rm -f /path/**/*.swp

\\\ ** matches any file or folder in an arbitrary sub-directory. Note that * just matches files and folders in the root directory.


**/.* matches any file beginning with a '.' (usually hidden files, like the .git folder) in an arbitrary sub-directory.



**/*.@(jpg|jpeg|gif|png) matches any file in an arbitrary sub-directory that ends with a '.' and exactly one of either 'jpg', 'jpeg', 'gif', or 'png'.\\\



For example,

In order to remove say, "*.jpg" files in all subdirectories of the folder called "/home/UB", one needs to access the UB folder. Just run the following commands one by one,

ls UB/


shopt -s globstar


rm **/*.jpg


2. Compress the size of PDF file

The objective is the reduce the size of mypdf.pdf

Use cd to get to the directory and then run the following command.

Method 1. Run the following commands

pdf2pdf mypdf.pdf

ps2pdf mypdf.ps

du -hs mypdf.pdf %gives you the reduced size of mypdf.pdf

Method 1. Using GhostScript.

Install GhostScript by using the following command

sudo apt-get install ghostscript

Then run,

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=1small.pdf mypdf.pdf

%1small.pdf is a reduced version of mypdf.pdf

3. Play with pdf files

There are some wonderful things you can do with the pdftk and those can be found at the following link,

https://www.pdflabs.com/docs/pdftk-cli-examples/




PS. Things written after % are comments, i.e do not consider them as a command.

No comments:

Post a Comment

A trip to Buzios, Arraial do Cabo and Cabo Frio - Brazil

What a wonderful trip it was I must say. Of course, there were some downs as well, as expected. We started off with Buzios.  If you ever pla...