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 [2020/01/04 07:59] 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> 
- 
- 
-===== printf ===== 
- 
-^Format^Description^ 
-|''%b''|Print the associated argument while interpreting backslash escapes in there| 
-|''%q''|Print the associated argument **shell-quoted**, reusable as input| 
-|''%d''|Print the associated argument as **signed decimal** number| 
-|''%i''|Same as ''%d''| 
-|''%o''|Print the associated argument as **unsigned octal** number| 
-|''%u''|Print the associated argument as **unsigned decimal** number| 
-|''%x''|Print the associated argument as **unsigned hexadecimal** number with lower-case hex-digits (a-f)| 
-|''%X''|Same as ''%x'', but with upper-case hex-digits (A-F)| 
-|''%f''|Interpret and print the associated argument as **floating point** number| 
-|''%e''|Interpret the associated argument as **double**, and print it in ''<N>±e<N>'' format| 
-|''%E''|Same as ''%e'', but with an upper-case ''E'' in the printed format| 
-|''%g''|Interprets the associated argument as **double**, but prints it like ''%f'' or ''%e''| 
-|''%G''|Same as ''%g'', but print it like ''%E''| 
-|''%c''|Interprets the associated argument as **char**: only the first character of a given argument is printed| 
-|''%s''|Interprets the associated argument literally as string| 
-|''%n''|Assigns the number of characters printed so far to the variable named in the corresponding argument. Can't specify an array index. If the given name is already an array, the value is assigned to the zeroth element.| 
-|''%a''|Interprets the associated argument as **double**, and prints it in the form of a C99 [[http://www.exploringbinary.com/hexadecimal-floating-point-constants/ | hexadecimal floating-point literal]].| 
-|''%A''|Same as ''%a'', but print it like ''%E''| 
-|''%(FORMAT)T''|output the date-time string resulting from using ''FORMAT'' as a format string for ''strftime(3)''. The associated argument is the number of seconds since Epoch, or ''-1'' (current time) or ''-2'' (shell startup time). If no corresponding argument is supplies, the current time is used as default| 
-|''%%''|No conversion is done. Produces a ''%'' (percent sign)| 
  
gnu-linux/bash.1578124777.txt.gz · Dernière modification : 2022/12/17 14:09 (modification externe)