Outils pour utilisateurs

Outils du site


gnu-linux:bash

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
gnu-linux:bash [2019/12/21 11:49] jockergnu-linux:bash [Date inconnue] (Version actuelle) – supprimée - modification externe (Date inconnue) 127.0.0.1
Ligne 1: Ligne 1:
-====== Bash ====== 
- 
-===== Aliases ===== 
- 
-Quelques aliases plus ou moins utiles. 
- 
-<code bash .bash_aliases> 
- 
-# wget2 
-alias wget="wget2 -c --progress bar" 
- 
-# Edit alias 
-alias aliases-edit="nano ~/.bash_aliases" 
-# Update alias 
-alias aliases-update="source ~/.bash_aliases" 
- 
-# Meteo 
-alias meteo="curl -H 'Accept-Language: fr' wttr.in/ladinhac" 
- 
-# cryptocurrencies 
-alias cryptocurrencies="curl eur.rate.sx" 
- 
-# cp, mv, rm, ls, du 
-alias rm="rm -v" 
-alias ls="ls -AFhoqv --color --group-directories-first" 
-alias ds="du -csh *  | sort -h -r" 
-alias tree="tree --du -h" 
- 
-# Reduce CD cover 
-cover-maker(){ 
-for img in *.gif *.GIF *.jpg *.JPG *.jpeg *.png *.PNG *.tif *.TIF *.bmp *.BMP; 
- do convert -quality 92 -resize 1000 "$img" cover.jpg 2> /dev/null && rm "$img" 2> /dev/null ; 
-done 
-} 
- 
-# top 15 size file 
-top15files(){ 
- find "$@" -printf '%s %p\n'| sort -nr | head -15 
-} 
- 
-# retirer parentheses et texte dedans 
-remove-parenthesis-content(){ 
- for file in * ; do mv -v "$file" "$(echo $file | sed 's/(.*)//')" ; done 
-} 
- 
-# Compresse séparément tout les fichiers d'un répertoire en zip 
-compress-all-zip(){ 
- SOURCE=$(wc -c * 2> /dev/null | grep "total" | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- for file in *.*; do zip "${file%.*}".zip "$file"; done 
- TARGET=$(wc -c *.zip 2> /dev/null | grep "total" | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- PERC=$(bc <<< "scale=2; ("$TARGET" - "$SOURCE")/"$SOURCE" * 100") 
- echo -e "The target(s) compressed file(s) does "$TARGET"MB, a difference of \e[1m$PERC%\e[0m from the source(s) ("$SOURCE"MB)." 
-} 
- 
-# Compresse séparément tout les fichiers d'un répertoire en xz 
-compress-all-xz(){ 
- SOURCE=$(wc -c * 2> /dev/null | grep "total" | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- for file in *.*; do tar -c -v "$file" | pxz -k -9 -c > "${file%.*}".tar.xz; done 
- TARGET=$(wc -c *.tar.xz 2> /dev/null | grep "total" | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- PERC=$(bc <<< "scale=2; ("$TARGET" - "$SOURCE")/"$SOURCE" * 100") 
- echo -e "The target(s) compressed file(s) does "$TARGET"MB, a difference of \e[1m$PERC%\e[0m from the source(s) ("$SOURCE"MB)." 
-} 
- 
-# Compresse séparément tout les fichiers d'un répertoire en lz4 
-compress-all-lz4(){ 
- SOURCE=$(wc -c * 2> /dev/null | grep "total" | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- for file in *.*; do tar -c -v "$file" | lz4 -9 > "${file%.*}".tar.lz4; done 
- TARGET=$(wc -c *.tar.lz4 2> /dev/null | grep "total" | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- PERC=$(bc <<< "scale=2; ("$TARGET" - "$SOURCE")/"$SOURCE" * 100") 
- echo -e "The target(s) compressed file(s) does "$TARGET"MB, a difference of \e[1m$PERC%\e[0m from the source(s) ("$SOURCE"MB)." 
-} 
- 
-# Compression tar.xz 
-compress-xz(){ 
-if [[ -d $@ ]]; then 
- time tar -c "$@" | pxz -k -9 -v -c > "${@%/}".tar.xz 
- echo 
- SOURCE=$(find "$@" -type f -exec wc -c {} \; | awk '{total += $1} END{print total}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- TARGET=$(wc -c "${@%/}".tar.xz | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- PERC=$(bc <<< "scale=2; ("$TARGET" - "$SOURCE")/"$SOURCE" * 100") 
- echo -e "The target compressed file does "$TARGET"MB, a difference of \e[1m$PERC%\e[0m from the source(s) ("$SOURCE"MB)." 
-else 
- time tar -c "$@" | pxz -k -9 -v -c > "${@%.*}".tar.xz 
- echo 
- SOURCE=$(wc -c "$@" | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- TARGET=$(wc -c "${@%.*}".tar.xz | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- PERC=$(bc <<< "scale=2; ("$TARGET" - "$SOURCE")/"$SOURCE" * 100") 
- echo -e "The target compressed file does "$TARGET"MB, a difference of \e[1m$PERC%\e[0m from the source(s) ("$SOURCE"MB)." 
-fi 
-} 
- 
-# Compression tar.lzo 
-compress-lzo(){ 
-if [[ -d $@ ]]; then 
- time tar -c "$@" | lzop -c -9 > "${@%/}".tar.lzo 
- echo 
- SOURCE=$(find "$@" -type f -exec wc -c {} \; | awk '{total += $1} END{print total}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- TARGET=$(wc -c "${@%/}".tar.lzo | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- PERC=$(bc <<< "scale=2; ("$TARGET" - "$SOURCE")/"$SOURCE" * 100") 
- echo -e "The target compressed file does "$TARGET"MB, a difference of \e[1m$PERC%\e[0m from the source(s) ("$SOURCE"MB)." 
-else 
- time tar -c "$@" | lzop -c -9 > "${@%.*}".tar.lzo 
- echo 
- SOURCE=$(wc -c "$@" | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- TARGET=$(wc -c "${@%.*}".tar.lzo | awk '{print $1;}' | awk '{ foo = $1 / 1024 / 1024 ; print foo}') 
- PERC=$(bc <<< "scale=2; ("$TARGET" - "$SOURCE")/"$SOURCE" * 100") 
- echo -e "The target compressed file does "$TARGET"MB, a difference of \e[1m$PERC%\e[0m from the source(s) ("$SOURCE"MB)." 
-fi 
-} 
- 
-# Compression tar.lz4 
-compress-lz4(){ 
-if [[ -d $@ ]]; then 
- time tar -c "$@" | lz4 -9 -v > "${@%/}".tar.lz4 
-else 
- time tar -c "$@" | lz4 -9 -v > "${@%.*}".tar.lz4 
-fi 
-} 
- 
-# Extraire une archive 
-function extract(){ 
- if [ -f "$1" ] ; then 
- case "$1" in 
- *.tar.xz)    tar -xvJf "$1"    ;; 
- *.tar.lzo)   lzop -d -c "$1" | tar xvf - ;; 
- *.tar.lz4)   lz4 -dcv "$1" | tar xvf - ;; 
- *.tar.lzma)  tar --lzma -xvf "$1" ;; 
- *.tar.bz2)   tar xvjf "$1"     ;; 
- *.tar.gz)    tar xvzf "$1"     ;; 
- *.bz2)       bunzip2 "$1"      ;; 
- *.rar)       unrar x "$1"      ;; 
- *.gz)        gunzip "$1"       ;; 
- *.tar)       tar xvf "$1"      ;; 
- *.tbz2)      tar xvjf "$1"     ;; 
- *.tgz)       tar xvzf "$1"     ;; 
- *.zip)       unzip "$1"        ;; 
- *.Z)         uncompress "$1"   ;; 
- *.7z)        7z x "$1"         ;; 
- *.7z.*)      7z x "$1"         ;; 
- *.iso)       7z x "$1"         ;; 
- *.img)       7z x "$1"         ;; 
- *)           echo "'$1' cannot be extracted via >extract<" ;; 
- esac 
- else 
- echo "'$1' is not a valid file!" 
- fi 
-} 
- 
-# Extraire plusieurs archives de meme type 
-function extract-all(){ 
- if [ -f "$1" ] ; then 
- case "$1" in 
- *.rar)       find . -name "*.rar" -exec unrar x {} \;    ;; 
- *.tar.xz)    find . -name "*.tar.xz" -exec tar -xvJf {} \;    ;; 
- *.zip)       find . -name "*.zip" -exec unzip {} \;        ;; 
- *.7z)        find . -name "*.7z" -exec 7z x {} \;         ;; 
- *)           echo "'$1' cannot be extracted via >extract<" ;; 
- esac 
- else 
- echo "'$1' is not a valid file!" 
- fi 
-} 
-</code> 
- 
  
gnu-linux/bash.1576928943.txt.gz · Dernière modification : 2022/12/17 14:09 (modification externe)