L’outil dos2unix n’est pas disponible par défaut sous Mac. Il existe bien entendu des alternatives, notamment avec l’outil ‘tr’, mais il est agréable également d’avoir à disposition dans sa boîte à outils ce petit utilitaire.
Pour l’installer, créez un script « makeDos2Unix.sh » et copiez-y le code ci-dessous. Une fois le fichier créé, il faut chmoder le fichier avec la commande suivante:
et lancez le script en tapant:
Lors de son exécution, le script va ouvrir la page web de l’outil, puis installer les différentes commandes sur votre Mac.
open -a Safari http://slagheap.net/darwin/
curl -L -O http://slagheap.net/darwin/dos2unix-051230.tar.gz
tar -xzf dos2unix-051230.tar.gz
cd dos2unix
export MAKEOBJDIR=.
sed -i "" -e 's/NOMANCOMPRESS/NO_MANCOMPRESS/' -e 's|/man/man|/share/man/man|' Makefile
bsdmake all
# perform a dry run to show install locations
# take the output of bsdmake's dry run, insert some newline characters and "echo" commands, then run it
bsdmake -n install |
sed \
-e 's/\([^;]\);\([^;]\)/\1'$'\\\n''\2/g' \
-e $'s/;;/&\\\n/g' \
-e $'s/do *case *\\$# *in/&\\\n/g' |
sed \
-e 's/^\( *install -.*\)/echo \1/' \
-e 's/^\( *\)\(rm \)/\1echo \2/' \
-e 's/^\( *\)\(ln \)/\1echo \2/' |
bash -s | uniq | grep -E '^(install|/)'
sudo bsdmake install
man dos2unix
La commande suivante, ci-dessous, permet d’arriver au même résultat sans avoir à installer l’exécutable dos2unix:
Source originale du script: http://codesnippets.joyent.com/posts/show/10939