The following CLI one-liner prints all the lines between the lines containing
PATTERN2 (including the lines with these two patterns) in a file, FILENAME:
sed -n '/PATTERN1/,/PATTERN2/p' FILENAME
Resize a picture or PDF file by 50% of its original form and save it as a PDF:
$ convert rose.jpg -resize 50% rose.pdf
Well, ‘convert’ may be used to convert between most of the known image formats —- not just JPG and PDF!
N.B. 1. More options may be found at the ImageMagick website. More information on how to specify the geometry may be found here. (If you don’t have ImgeMagick you need to install it first — see the first link for more information on installation!).
2. Here is a list of other useful options/ examples on how to make the best out of ‘convert’.
3. If you’re at playing with PDFs you may also be interested in joining and removing pages from a PDF document using Ghostscript — see a previous post here.
If you use print in awk you’ll lose the formatting of the input file — most of the times that may be OK, but not always. The solution is simple — replace print by printf. Here’s an example with strings in the input fields:
- “%…s” means a character string.
- 20 means a length of 20 characters.
- awk defaults to right-alignment (presumably for columns of figures) so you need -20 for left-alignment.
CUPS = Common UNIX Printing System
In order to search for the CUPS based printers connected to the computer (directly or via a network), use this command in the terminal:
or type in the address field of a browser:
The following file controls the cups configurations:
Make sure you configure the file as follows:
1. Tell cupsd to listen broadcasts. This can be done by turning Browsing on
2. Tell cupsd to listen broadcasts from other than local network as well.
Combine pdf files:
which combines pdffile1.pdf and pdffile2.pdf into a single ouput.pdf.
Delete certain pages of a PDF document:
where m and n are positive integers (page numbers), i.e. the above command only prints out pages starting from page number m through n of input.pdf into output.pdf.