Un ensemble de scripts bien utile pour simplifier quelques conversions
0x01. DMG2ISO
#!/bin/bash APP="dmg2iso" source $HOME/.local/_include/colors.sh function usage { printf " Usage: $APP <file.dmg> <file.iso> hdiutil convert -format UDTO -o fichier.iso fichier.dmg " exit $1 } function error { printf " $APP: $1 " exit $2 } [ $# -ne 2 ] && usage 0 F_DMG="$1" F_ISO="$2" [ ! -f "$F_DMG" ] && error "unable to read: $F_DMG" touch "$F_ISO" [ ! -w "$F_ISO" ] && error "unable to write: $F_ISO" printf " Using $W""hdiutil$B Apple MacOSX included program : $W""hdiutil convert -format UDTO -o '$F_ISO' '$F_DMG' $B\n" hdiutil convert -format UDTO -o "$F_ISO" "$F_DMG"
0x02. IMG2DMG
#!/bin/bash APP="dmg2iso" source $HOME/.local/_include/colors.sh function usage { printf " Usage: $APP <file.img> <file.dmg> hdiutil convert -format UDSB -o fichier.iso fichier.Img " exit $1 } function error { printf " $APP: $1 " exit $2 } [ $# -ne 2 ] && usage 0 F_IMG="$1" F_DMG="$2" [ ! -f "$F_IMG" ] && error "unable to read: $F_IMG" touch "$F_DMG" [ ! -w "$F_DMG" ] && error "unable to write: $F_DMG" printf " Using $W""hdiutil$B Apple MacOSX included program : $W""hdiutil convert -format UDTO -o '$F_DMG' '$F_IMG' $B\n" hdiutil convert -format UDTO -o "$F_DMG" "$F_IMG" mv -f "$F_DMG.cdr" "$F_DMG"
0x03. IMG2ISO
#!/bin/bash img=$1 iso=$(echo $1|sed 's:\.img$:\.iso:1') echo "'$img' -> '$iso'" echo '---' hdiutil convert -format UDTO -o "$iso" "$img" echo '---' mv -v "$iso.cdr" "$img" echo '---' echo
0x04. ICNS2PNG
#!/bin/bash if [ $# -ne 1 -o ! -f "$1" ]; then echo " Usage: $(basename $0) <image.icns> " tail -n2 $0 exit 0 fi src=$(ls -1 "$1") dst=$(ls -1 "$1"|sed 's/.icns$/.png/1') echo $src" -> "$dst sips -s format png "$src" --out "$dst"
0x05. PNG2ICNS
#!/bin/bash if [ $# -ne 1 -o ! -f "$1" ]; then echo " Usage: $(basename $0) <image.png> " tail -n2 $0 exit 0 fi src=$(ls -1 "$1") dst=$(ls -1 "$1"|sed 's/.png$/.icns/1') err=0 ; sips -s format icns "$src" --out "$dst" 2>&1 |grep "Unable" && err=1 exit $err
0x06. SVC2PORT
#!/bin/bash APP="port2svc" function usage() { printf " Usage: $APP <port> [protocol] Script will show which service is assigned to port by reading /etc/services \n\n" exit $1 } PROT="tcp" if [ $# -gt 2 -o $# -lt 1 ] then usage 0 fi PORT=$1 [ $# -eq 2 ] && PROT=$2 grep -iP "\s$PORT/$PROT" /etc/services #| sed 's/#//' | awk {'print $3" "$4" "$5" "$6'} |sort -u
0x07. PORT2SVC
#!/bin/bash APP="port2svc" function usage() { printf " Usage: $APP <service> [protocol] Script will show which service is assigned to port by reading /etc/services \n\n" exit $1 } PROT="tcp" if [ $# -gt 2 -o $# -lt 1 ] then usage 0 fi SVC=$1 PROT=$2 grep -iE "^$SVC " /etc/services | grep "$PROT" #|sed 's/#//' | awk {'print $3" "$4" "$5" "$6'} [ $? -ne 0 ] && grep -iE "$SVC " /etc/services | grep "$PROT" #|sed 's/#//' | awk {'print $3" "$4" "$5" "$6'}
=> Écrit par : Nicolas, le 28 avril 2016