4259 links
  • Arnaud's links
  • Home
  • RSS Feed
  • Tag cloud
  • Login
search: tag:bash — newest first
  • Note: bash date

    date +%Y-%m-%d_%H-%M-%S

    June 5, 2020 - permalink - https://links.infomee.fr/shaare/jh3dRw
    bash date
  • [Feature] Auto Fix · Issue #1220 · koalaman/shellcheck · GitHub

    shellcheck a maintenant une option pour auto fix

    shellcheck restore.sh -f diff | git apply

    September 11, 2019 - permalink - https://github.com/koalaman/shellcheck/issues/1220
    bash shellcheck
  • Using Temporary Security Credentials to Request Access to AWS Resources - AWS Identity and Access Management

    Use role in script

    November 21, 2017 - permalink - http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html?shortFooter=true#using-temp-creds-sdk-cli
    aws bash cli role
  • Note: bash get random element from string "elem1;elem2;elem3"
    #!/bin/bash
    
    servers="server1;server2;server3"
    
    IFS=';' read -r -a array <<< "$servers"
    
    rand=$[ $RANDOM % ${#array[@]} ]
    
    echo ${array[$rand]}
    
    October 5, 2017 - permalink - https://links.infomee.fr/shaare/wfMNvw
    bash random
  • GitHub - hbekel/magic: define bash functions on a per-directory basis

    C'est magique

    May 28, 2017 - permalink - https://github.com/hbekel/magic
    bash
  • Bash scripting quirks & safety tips - Julia Evans

    set -eux
    Shellcheck
    reptyr

    April 2, 2017 - permalink - http://jvns.ca/blog/2017/03/26/bash-quirks/
    bash
  • Note: How to know which policy contains a specific action?

    Warning : this loop does a lot of call to aws api, use it with caution

    To know that I needed to list all policies and associated statements (for the default policy version)

    #!/bin/bash
    IFS=$'\n'
    for line in $(aws iam list-policies|jq '.Policies|.[]|[ .PolicyName, .Arn, .DefaultVersionId ]| @csv' -r|sed 's/","/ /g'|sed 's/"//g'); do
        name=$(echo $line|cut -d' ' -f1);
        arn=$(echo $line|cut -d' ' -f2);
        version=$(echo $line|cut -d' ' -f3);
        echo "$name"
        aws iam get-policy-version --policy-arn $arn --version-id $version
    done
    

    Put this in a script, redirect output to a file and go get grep!

    February 22, 2017 - permalink - https://links.infomee.fr/shaare/bERNcg
    aws bash for foreach iam nomarkdown policy separator
  • Note: function pour log en bash

    Je me mets ça de côté pour gagner du temps la prochaine fois

    !/bin/bash

    logfile=/tmp/logfile.log
    errorfile=/tmp/error.log

    function log() {
    echo -e "\e[34m\e[1m[$(date +%Y-%m-%d) $(date +%H:%M:%S)] $1\e[0m" | tee -a /tmp/logfile.log
    }

    function logerror() {
    echo -e "\e[91m\e[1m[$(date +%Y-%m-%d) $(date +%H:%M:%S)] $1\e[0m" | tee -a /tmp/logfile.log
    }

    log "prout"
    logerror "pwet"

    February 10, 2017 - permalink - https://links.infomee.fr/shaare/tQ0ssA
    bash function log
  • How to install bash shell in Alpine Linux
    February 7, 2017 - permalink - https://www.cyberciti.biz/faq/alpine-linux-install-bash-using-apk-command/
    alpine ash bash
  • The Bash Hackers Wiki [Bash Hackers Wiki]
    June 8, 2016 - permalink - http://wiki.bash-hackers.org/
    bash
  • Detecting the use of "curl | bash" server side | Application Security

    :o

    April 22, 2016 - permalink - https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-bash-server-side/
    bash curl security
  • jimeh/git-aware-prompt: Display current Git branch name in your terminal prompt when in a Git working directory.

    Ptetre qu'un jour je passerai à zsh (ohmyzsh)

    En attendant je bricole

    February 4, 2016 - permalink - https://github.com/jimeh/git-aware-prompt
    ai bash git prompt
  • Check incoming update from puppet forge

    Un petit script pour check si les modules ont de nouvelles version dispo (il faut jq)

    #!/bin/bash
    
    modules=$(puppet module list|grep '\(v[0-9]\.[0-9]\.[0-9]\)')
    
    IFS=$'\n'
    for line in $modules; do
        name=$(echo $line|cut -d' ' -f2)
        version=$(echo $line|grep -o '\(v[0-9]\.[0-9]\.[0-9]\)'|sed 's/v//')
        current_version=$(curl -s https://forgeapi.puppetlabs.com/v3/modules/${name}|jq '.current_release.version'|sed 's/"//g')
        if [[ $version == $current_version ]]; then
            echo "OK $name $version $current_version"
        else
            echo "OUTDATED $name $version $current_version"
        fi  
    done
    
    November 30, 2015 - permalink - https://links.infomee.fr/shaare/6tdMVA
    IFS bash for forge loop module puppet
  • jneen/balls

    :D
    via nico

    August 24, 2015 - permalink - https://github.com/jneen/balls
    bash
  • bash value toi great for base

    $((10#$number))

    July 9, 2015 - permalink - http://ubuntuforums.org/showthread.php?t=677751
    base bash
  • Marks

    Je ne sais plus ou j'ai vu ça, je ne retrouve plus le lien donc je me le remets ici au cas où

    Marks

    export MARKPATH=$HOME/.marks
    function jump {
    cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
    }
    function mark {
    mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
    }
    function unmark {
    rm -i "$MARKPATH/$1"
    }
    function marks {
    ls -l "$MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
    }

    June 12, 2015 - permalink - https://links.infomee.fr/shaare/XYagKw
    bash bashrc mark
  • Use the Unofficial Bash Strict Mode (Unless You Looove Debugging)
    January 1, 2015 - permalink - http://redsymbol.net/articles/unofficial-bash-strict-mode/
    bash
  • Explain: {,} in cp or mv Bash Shell Commands
    January 1, 2015 - permalink - http://www.cyberciti.biz/faq/explain-brace-expansion-in-cp-mv-bash-shell-commands/
    bash
  • Être à l'aise avec bash #5 (bash, debian, linux, shell, ssh, truc, ubuntu) - Damien Pobel / blog
    January 1, 2015 - permalink - http://damien.pobel.fr/post/etre-a-l-aise-avec-bash-5
    bash
  • Bash Initialisation Files

    via skunnyk

    November 19, 2014 - permalink - http://www.solipsys.co.uk/new/BashInitialisationFiles.html
    bash intialisation
  • Afficher l'original d'un fichier qui provient d'un package sous debian en une commande

    à mettre dans son bashrc

    showOriginal() {

    argument = complete path to a file

    output original file content

    packageName=$(dpkg -S $1|cut -d':' -f1)
    tmpdir="/tmp/showOriginal-$packageName-$(date +%s)"
    mkdir $tmpdir
    cd $tmpir
    apt-get download $packageName > /dev/null
    dpkg -x *.deb $tmpdir
    cat ${tmpdir}$1
    cd - >/dev/null
    rm -rf $tmpdir
    }

    September 26, 2014 - permalink - https://links.infomee.fr/shaare/tdQ_tA
    bash bashrc script
  • Quickly navigate your filesystem from the command-line

    jusqu'à présent j'utilisais des alias dans mon bashrc du genre :
    cdbackup() { cd /home/foo/backup/; }

    Mais la méthode proposée est bien plus pratique

    August 8, 2014 - permalink - http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
    bash shell
  • Why Zsh is Cooler than Your Shell

    zsh ça a l'air bien quand même. Le coup des alias inline ça rox ( gp=|grep -i )

    June 29, 2014 - permalink - http://www.slideshare.net/jaguardesignstudio/why-zsh-is-cooler-than-your-shell-16194692
    bash shell zsh
  • Defensive BASH programming - Say what?

    via arnaudb

    June 2, 2014 - permalink - http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/
    bash
  • xclip - Documentation Ubuntu Francophone

    Bien pratique pour intéragir avec le pressepapier en cmdline, exemple :

    function nowplz {
    xclip -i <<< $(date "+%Y-%m-%d %H:%M")
    }

    va copier dans le presse papier la date et l'heure actuelle

    March 27, 2014 - permalink - http://doc.ubuntu-fr.org/xclip
    bash clipboard presse_papier
  • Running commands in parallell using bash | Michael Boman

    bien utile

    cat liste | parallel --gnu -j 10 ssh root@{} 'ls'

    March 20, 2014 - permalink - http://blog.michaelboman.org/2012/04/running-commands-in-parallel-using-bash.html
    background bash parallel
  • sorting - Bash - Difference Between two lists - Stack Overflow

    Pour obtenir la diff des éléments entre deux listes :

    To get the lines only in the old file:
    comm -23 <(sort /tmp/oldList) <(sort /tmp/newList)

    To get the lines only in the new file:
    comm -13 <(sort /tmp/oldList) <(sort /tmp/newList)

    comm -23 <(sort /tmp/1) <(sort /tmp/2)
    comm -13 <(sort /tmp/1) <(sort /tmp/2)

    March 19, 2014 - permalink - http://stackoverflow.com/questions/11165182/bash-difference-between-two-lists
    bash comm diff list
  • mktemp

    Pratique pour l'écriture de script en bash lorsqu'on a besoin d'un fichier temporaire :

    Creation

    tmpfile=$(mktemp)

    Utilisation...

    Clean

    if [ -e "$tmpfile" ]
    then
    rm -f $tmpfile
    fi

    March 19, 2014 - permalink - https://links.infomee.fr/shaare/r6stZw
    bash mktemp tmp tweetit
  • BashGuide/InputAndOutput - Greg's Wiki

    You can avoid this by temporarily removing the indentation for the lines of your Heredocs. However, that distorts your pretty and consistent indentation. There is an alternative. If you use <<-END instead of <<END as your Heredoc operator, Bash removes any tab characters in the beginning of each line of your Heredoc content before sending it to the command. That way you can still use tabs (but not spaces) to indent your Heredoc content with the rest of your code. Those tabs will not be sent to the command that receives your Heredoc. You can also use tabs to indent your sentinel string.

    February 28, 2014 - permalink - http://mywiki.wooledge.org/BashGuide/InputAndOutput
    bash heredoc
  • Execute local script remotly and get ouput into a local log file

    Cool stuff :

    ssh user@server 'bash -s' < local_script.sh > local_script.log 2>&1

    January 31, 2014 - permalink - https://links.infomee.fr/shaare/ORnmyQ
    bash ssh
  • Command line one-liners | Arturo Herrero

    Sympa tous ces one liners ! il y a même un repo dans lequel on peut ajouter les siens : https://github.com/fxn/tkn

    Mes préférés :
    $ echo "!!" > script.sh
    $ cp file.txt{,.bak}
    $ (cd /tmp && ls)
    $ nc -l 5566 > data-dump.sql
    $ nc 5566 < data-dump.sql

    via Olivier

    January 22, 2014 - permalink - http://arturoherrero.com/2013/11/29/command-line-one-liners/
    bash commandline linux
  • More on Using Bash's Built-in /dev/tcp File (TCP/IP) | Linux Journal

    Créer une socket en bash :o

    January 10, 2014 - permalink - http://www.linuxjournal.com/content/more-using-bashs-built-devtcp-file-tcpip
    bash socket tcp
  • Deux syntaxes pour écrire une fonction en bash

    function sayhello() {
    echo hello
    }

    OR

    sayhello() {
    echo hello
    }

    Et en one-line :

    sayhello() { echo hello; }

    January 2, 2014 - permalink - https://links.infomee.fr/shaare/zlvmKw
    bash fonction function
  • 12 Best Practices for Writing Bash Scripts - Kevin van Zonneveld

    Quelques bp sur bash

    December 2, 2013 - permalink - http://kvz.io/blog/2013/11/21/bash-best-practices/
    bash
  • Returning Values from Bash Functions | Linux Journal

    Je prefere la deuxieme solution :

    function myfunc()
    {
    local myresult='some value'
    echo "$myresult"
    }

    result=$(myfunc) # or result=myfunc
    echo $result

    November 14, 2013 - permalink - http://www.linuxjournal.com/content/return-values-bash-functions
    bash function
  • How to iterate over associative array in bash - Stack Overflow

    Comment déclarer et itérer sur un tableau associatif en bash :

    declare -A array
    array[foo]=bar
    array[bar]=foo

    for i in "${!array[@]}"
    do
    echo "key : $i"
    echo "value: ${array[$i]}"
    done

    November 14, 2013 - permalink - http://stackoverflow.com/questions/3112687/how-to-iterate-over-associative-array-in-bash
    array associative bash iterate
  • Bash Argsparse : mieux gérer sa ligne de commande dans ses scripts. - LinuxFr.org

    à voir, il y a aussi getopts

    November 5, 2013 - permalink - http://linuxfr.org/news/bash-argsparse-mieux-gerer-sa-ligne-de-commande-dans-ses-scripts
    arg argparse bash parse
  • showterm

    Un truc pour faire du screencast de terminal, ça peut servir

    October 23, 2013 - permalink - http://showterm.io/
    bash enregistrement screencast terminal
  • Cheat - Pour vous souvenir de la bonne syntaxe « Korben Korben

    Old mais je viens d'y repenser. Finalement je fais pareil, j'ai des mémo pour chaque commande dans un dossier de mon dropbox alors pourquoi pas essayer de les utiliser avec ça ? à tester. Dans tous les cas ça ne doit pas remplacer le man

    October 23, 2013 - permalink - http://korben.info/cheat-pour-vous-souvenir-de-la-bonne-syntaxe.html
    bash cheat console man memo shell syntax syntaxe
  • BashGuide - Greg's Wiki

    this one is good

    October 22, 2013 - permalink - http://mywiki.wooledge.org/BashGuide
    bash tuto
  • List of Bash online-tutorials [Bash Hackers Wiki]
    October 20, 2013 - permalink - http://wiki.bash-hackers.org/scripting/tutoriallist
    bash cours tutorial
  • Learning the shell - Lesson 6: I/O Redirection
    October 20, 2013 - permalink - http://linuxcommand.org/lts0060.php
    bash il redirection shell stdin stdout
  • How can I use an at command in a shell script? - Stack Overflow

    at now +10 minutes <<< "rm -rf /tmp/tobedeleted"

    at now +1 minutes <<< "init 6"

    /etc/init.d/networking stop && /etc/init.d/networking start

    atq

    atrm 2

    For multiline, consider a "HERE-doc"

    at now +10 minutes <<ENDMARKER
    rm -rf /tmp/tobedeleted
    echo all done | mail -s 'completion notification' sysadmin@example.com
    ENDMARKER

    October 20, 2013 - permalink - http://stackoverflow.com/questions/15454199/how-can-i-use-an-at-command-in-a-shell-script
    at bash
  • Portknocking in bash

    Un serveur, mais surtout un client pour faire du port knocking

    October 15, 2013 - permalink - http://www.prometheus-group.com/labs/unbounded/46-web-security/135-bash-pk.html
    bash knocking port portknocking serveur ssh
  • Screen for remote session management :D

    screen -S machineA (ensuite on se co en ssh à machineA, puis CTRL A D pour detach)
    screen -S machineB (ensuite on se co en ssh à machineB, puis CTRL A D pour detach)
    etc
    At the end of the day :
    screen -ls affiche tous les screens (avec chacun une connexion vers le serv en ssh)
    screen -r machineA pour aller sur le A
    screen -r machineB pour aller sur le B

    alias utiles :
    alias sls='screen -ls' #Pour lister les screen
    alias sr='screen -r' #Pour recover un screen
    alias sn='screen -S' #Pour créer un nouveau screen

    October 14, 2013 - permalink - https://links.infomee.fr/shaare/VQzf3w
    bash screen
  • bash - How do you find the age of a long-running Linux process and then kill it? - Stack Overflow
    October 10, 2013 - permalink - http://stackoverflow.com/questions/6134/how-do-you-find-the-age-of-a-long-running-linux-process-and-then-kill-it
    bash etime process time
  • Bash String Manipulation Examples – Length, Substring, Find and Replace

    Manipulation de string en bash

    September 9, 2013 - permalink - http://www.thegeekstuff.com/2010/07/bash-string-manipulation/
    bash concat string
  • Programmation Bash/Flux et redirections - Wikilivres

    com > fic redirige la sortie standard de com dans le fichier fic,
    com 2> fic redirige la sortie des erreurs de com dans le fichier fic,
    com 2>&1 redirige la sortie des erreurs de com vers la sortie standard de com,
    com < fic redirige l'entrée standard de com dans le fichier fic,
    com1 | com2 redirige la sortie standard de la commande com1 vers l'entrée standard de com2.

    September 3, 2013 - permalink - http://fr.wikibooks.org/wiki/Programmation_Bash/Flux_et_redirections
    bash in out std
  • explainshell.com - match command-line arguments to their help text

    Petit outil sympa qui donne l'explication de n'importe quelle commande shell (on peut c/c ce qu'on veut)l

    August 30, 2013 - permalink - http://www.explainshell.com/
    bash help linux man shell
  • What I learned from other's shell scripts
    August 14, 2013 - permalink - http://www.fizerkhan.com/blog/posts/What-I-learned-from-other-s-shell-scripts.html
    bash shell
▼ Load 50 more