Paquets du terminal


C’est le dossier où sont installés les packages utilisés dans le terminal ! tout est là !!


String manipulation :

Variables dans script bash

Fun with the terminal (créer une arbo w/ le terminal, e.g.)

Tree (pour faire des arbos)

Changer la date de création/modification d’un fichier

touch -mt 200801120000 /Volumes/Mac\ HD/Pictures/Album

Batch rename files with rename (not installed by default)

The syntax of “rename” is quite complicated though, its general form is:

rename 's/old-name/new-name/' filespec  

For example, to change all .txt files to .doc, the command will be:

rename 's/txt/doc/' *  

This command will change the “txt” part of the file names into “doc”. However a problem may occur if the part “txt” also appears in the name of the files. The better command to change .txt file to .doc will be:

rename 's/txt$/doc/' *  

This command will change “txt” into “doc” in any file that has “txt” in the end of the file name, which means that if a file with no extension ends with “txt”, it will be renamed too. Thats why the best command to change all .txt files to .doc will be:

rename 's/\.txt/\.doc/' *    

This command will change all the .txt extensions into .doc without caring about the part before the extension.

Another example is to remove the hyphen(“-“) before the file names, your command will be:

rename 's/-*//' *    

If you have a collection of songs sung by the same singer, to add the singer’s

rename 's//singers-name-/' *.mp3  

In case you want to remove or change a part that appears multiple times in the file names ( for example, kakarot.png, kanaka.txt, bakaka.mp3 ….), if you use any of the above commands, only the first “ka” will be changed or removed. To remove or change all these “ka”, you will need to use the “g” (global) option. For example,the command to remove all the “ka” in the name of all files will be:

rename 's/ka//g' *

With this command, all the “ka” parts will be erased from the name of all files in the current folder.

Note Since the syntax of rename is complicated, you may very likely make mistakes. If you want to make sure everything is right, you should use the -n parameter (means “no action”) first with rename to check the output. The command will be like this:

rename -n 's/ka//g' *  

The output of the rename command will be displayed in the terminal but nothing is changed. If everything looks good, you can run the actual command without -n.

Besides the “s” option ( means substitute), “y” (means translate) is another thing you can try with rename. For example, to convert all the file names from low letters to capital letters, you can use this command:

rename 'y/A-Z/a-z/' *  

See more at: «> files-with-rename.html#sthash.BtgCAb0g.dpuf>

With mv (installed by default on OSX)

In your specific case you can use the following bash command (bash is the default shell on OSX):

for f in*.png;do echo mv "$f""${f/_*_/_}";done

Note that echo is prepended to mv so as to perform a dry run. Remove it to perform actual renaming.

You can run it from the command line or a script.

If you find yourself batch-renaming files frequently, consider a specialized tool such as the Perl-based [rename utility]( On OSX you can install it using popular package manager [Homebrew]( as follows: `brew install rename`

Here’s the equivalent command using rename:

rename -n -e 's/_.*_/_/'*.png

Again, this command performs a dry run; remove -n to perform actual renaming.

Similar to the bash solution, s/.../.../ performs text substitution, but - unlike in bash - true regular expressions are used.

Change uppercase to lowercase in a folder, recursively

rename 'y/A-Z/a-z/' *

Trouver tous les éléments dans tous les sous-dossiers,

puis changer l’extension de .md en .txt

find . -iname "*md*" -exec rename 's/.md$/.txt/' '{}' \;

Source :

Télécharger toutes les images d’un site avec wget

wget -r -A=.jpg,.png,.gif,.JPG,.PNG,.GIF --random-wait --limit-rate=100k < -o log>

Toutes celles d’une page wget -r -l1 –no-parent -A=.jpg,.png,.gif,.JPG,.PNG,.GIF

Capture la page d’un site

w/ pageres-cli

sudo npm install -g pageres-cli


pageres 1024x768

w/ wkhtmltoimage

sudo apt install wkhtmltopdf


wkhtmltoimage google.jpg

plus complet

wkhtmltoimage --height 1200 --width 800 google.png

Comparer deux pdf

contiennent du texte

pdftotext file1.pdf
pdftotext file2.pdf
diff file1.txt file2.txt

pdf image Regarder ce lien, le script est assez long >

Convertir un pdf en images

convert input.pdf output.jpg #convertit toutes les pages en jpg > output-0.jpg, output--1.jpg, etc.

pour paramétrer la résolution de sortie : ex. 300 dpi

convert -density 300 input.pdf output.jpg