Reference

https://www.gnu.org/software/bash/manual/bashref.html#Pipelines

Paquets du terminal

/usr/local/bin

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

Reference

String manipulation : http://www.tldp.org/LDP/abs/html/string-manipulation.html

Variables dans script bash

https://www.lifewire.com/pass-arguments-to-bash-script-2200571

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

http://www.cnet.com/news/terminal-fun-options-for-printing-folder-and-subfolder-contents/

Tree (pour faire des arbos)

http://mama.indstate.edu/users/ice/tree/

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

https://medium.com/@danilosapad/how-to-change-a-file-s-last-modified-and-creation-dates-on-mac-os-x-494f8f76cdf4#.74c9hmf4y

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: <http://www.linuxandlife.com/2013/02/how-to-rename-multiple- 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.

  • "${f/_*_/_}" is an application of bash parameter expansion: the (first) substring matching pattern _*_ is replaced with literal _, effectively cutting the middle token from the name.
  • Note that the pattern used is a wildcard expressions, not a regular expressions (run man bashand search for Pattern Matching).

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 : http://stackoverflow.com/questions/16541582/finding-multiple-files-recursively-and-renaming-in-linux

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 http://pilierskernilis.pagesperso-orange.fr/ -o log

Toutes celles d’une page wget -r -l1 –no-parent -A=.jpg,.png,.gif,.JPG,.PNG,.GIF https://publicdomainreview.org/collections/landscapes-of-the-western-front-1914-1918/l

Capture la page d’un site

w/ pageres-cli

sudo npm install -g pageres-cli

puis

pageres todomvc.com 1024x768

https://github.com/sindresorhus/pageres-cli

w/ wkhtmltoimage

sudo apt install wkhtmltopdf

puis

wkhtmltoimage google.com google.jpg

plus complet

wkhtmltoimage --height 1200 --width 800 google.com 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 > https://stackoverflow.com/questions/6469157/pdf-compare-on-linux-command-line

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