Affichage des articles dont le libellé est shell bash. Afficher tous les articles
Affichage des articles dont le libellé est shell bash. Afficher tous les articles

lundi 31 août 2020

Rsync and exclusions

 

an old post found back on disqr about rsync (original date : circa 2016)

You might want to use the rsync exclude options directly in your script either by specifying a file with all the exclusions to perform, or by specifying them in the command line directly :

--exclude-from <file-name with 1 pattern by line>
--exclude <file or="" dir="">

For example :

rsync -r -a -v -e "ssh -l Username" \
        --exclude 'dbconfig.xml' --exclude 'WEB-INF/classes/' --delete \
        /local/Directory remote.server:/remoteDirectory

One important thing to keep in mind when excluding a directory is that rsync will always consider the path to be relative to the source directory.



This can be used for example when you want to push your production from a Production JIRA instance to a Staging JIRA instance, but your dbconfig.xml is different (different DB auth parameters for example), and hence want to avoid some files. 

jeudi 12 juillet 2012

Command(s) of the day

Some colleagues started putting commands on the white-board every X days under
  • comm compare two sorted files line by line
  • paste merge lines of files
  • colordiff diff, with colors
  • colorgcc
  • pgrep look for a process name
  • pkill kill processes by name, not by pid
  • ...

jeudi 16 février 2012

signaux et terminaux, stty

A la base, une simple question de la part d'une collègue : comment envoyer un SIGQUIT dans un terminal sous mac OS.
Une rapide recherche sur le net donne comme réponse "^\", contrairement à linux où c'est usuellement "^d" qui sert à cela.

Comment configurer cela, comment trouver cela ?


STTY(1)                          User Commands                         STTY(1)
NAME
       stty - change and print terminal line settings

SYNOPSIS
       stty [-F DEVICE | --file=DEVICE] [SETTING]...
       stty [-F DEVICE | --file=DEVICE] [-a|--all]
       stty [-F DEVICE | --file=DEVICE] [-g|--save]

DESCRIPTION
       Print or change terminal characteristics.

Qui chez moi par exemple (Ubuntu) me donne :
 
$ stty -a
speed 38400 baud; rows 40; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?;
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt 
Donc en fait "^d" envoie un "eof", pas un sig_quit...

jeudi 7 octobre 2010

Option Dash Dash

Une propriété intéressante des outils gnu,bsd&cie. est la possiblité d'indiquer la fin du passage des options avec un "--" (dash dash).

Pratique par exemple pour faire un grep sur quelquechose qui pourrait ressembler à une option, sans que la chaine à chercher ne soit interprétée comme otion de grep. Mais ce n'est qu'un exemple.


Application, pour chercher toutes les occurences de '-l' dans le fichier 'toto.txt' :

grep -- -l toto.txt

mardi 15 décembre 2009

Bash tricks ":", la commande qui ne fait rien

En bash, la commande ":" ("column", ou "deux points") est une commande qui prend autant d'arguments que l'on veut mais qui ne fait rien.

C'est en particulier pratique pour commenter dynamiquement du code.
Par exemple :


#!/bin/bash
#DEBUG=echo
DEBUG=:

if [ -f /tmp/toto ]; then
$DEBUG "/tmp/toto existe"
echo `date` >>/tmp/toto
else
$DEBUG "/tmp/toto n'existe pas"
echo "fichier cree a `date`" > /tmp/toto

fi


Exem

mercredi 4 mars 2009

commandlinefu

Fantastique !

http://www.commandlinefu.com

c'était un peu l'idée de ce blog au départ, bien que cela ait un peu dévié...

En se retrouve sur ce site avec un équivalent twitter, mais uniquement pour des lignes de commande !

exemple, cette commande que j'avais eu l'occasion de chercher un jour pour une vidéo prise avec mon appareil photo...
mencoder -vf rotate=1 -ovc lavc -oac copy "$1" -o "$1"-rot.avi