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/04/07 08:23] 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> 
-# Edit alias 
-alias aliases-edit="nano ~/.bash_aliases" 
-# Update alias 
-alias aliases-update="source ~/.bash_aliases" 
- 
-# cp, mv, rm, ls, du 
-alias cp="/usr/bin/cpg --progress" 
-alias mv="/usr/bin/mvg --progress" 
-alias rm="rm -v" 
-alias ls="ls -AFhoqv --color --group-directories-first" 
-alias ds="du -csh *  | sort -h -r" 
- 
-cover-maker(){ 
-for img in *.jpg *.JPG *.jpeg *.png *.PNG; 
-        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 -k9 -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)." 
-} 
- 
-# Compression tar.xz 
-compress-xz(){ 
-if [[ -d $@ ]]; then 
-    time tar -c "$@" | pxz -k9 -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 -k9 -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 > "${@%/}".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 > "${@%.*}".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 
-} 
- 
-# Extract 
-function extract(){ 
-    if [ -f "$1" ] ; then 
-        case "$1" in 
-            *.tar.xz)    tar -xvJf "$1"    ;; 
-            *.tar.lzo)   lzop -d -c "$1" | tar xvf - ;; 
-            *.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"         ;; 
-     *.iso)       7z x "$1"         ;; 
-            *)           echo "'$1' cannot be extracted via >extract<" ;; 
-        esac 
-    else 
-        echo "'$1' is not a valid file!" 
-    fi 
-} 
-</code> 
- 
  
gnu-linux/bash.1554625402.txt.gz · Dernière modification : 2022/12/17 14:09 (modification externe)