Skip to content

Instantly share code, notes, and snippets.

@ColinLeverger
Last active December 8, 2016 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ColinLeverger/c921aa6b10201a14e94ad1d11c5f41a4 to your computer and use it in GitHub Desktop.
Save ColinLeverger/c921aa6b10201a14e94ad1d11c5f41a4 to your computer and use it in GitHub Desktop.
Toolbox Bash

Toolbox

Delete files with find + grep

find -L /path/to/dir -name "*name*" -print0 |xargs -0 -r rm

Find differences between two files

diff fichier1 fichier2 grep -f fichier1 fichier2

Format SD card (FAT32) on Mac:

  1. Mount the card
  2. sudo diskutil eraseDisk FAT32 SDCARD MBRFormat /dev/diskX (find diskX with diskutil list)

Install tar.gz :

tar -zxvf file.tar.gz

Find PID of a process:

pidof <process>

Caractere encoding problem

Find accented chars on a file:

grep -P -n "[\x80-\xFF]" file.txt

... And invisibles ones:

grep '[^[:print:]]' file

... And solve encoding problems once and forall:

native2ascii fileDépart fileArrivee diff fileDépart fileArrivee

VIM

:.,$d -> suprime le contenu du fichier depuis le curseur jusqu’à la fin du fichier :1,$d -> supprime TOUT le contenu du fichier :G -> goto end of file :%s/foo/bar/g -> remplacer tout les foo en bar

PS

To see every process on the system using standard syntax:

ps -ef

To see every process on the system using BSD syntax:

ps aux

-ef = full aux = user oriented

TAR

Compress a folder

tar czf name_of_archive_file.tar.gz name_of_directory_to_tar

Resise a set of images

sips -Z 600 *.jpg

-Z : keep proportions 640 : taille heigh max

Count chars on PDF

pdftotext file.pdf -enc UTF-8 - | tr -d "." | tr -s " \n" | wc -c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment