<?xml version="1.0" encoding="UTF-8" ?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
    <title>Posteet: bash,shell</title> 
    <link>http://www.posteet.com/</link> 
    <description>Recent posteets posted to Posteet</description>
    <ttl>60</ttl>

    
    <item>
        <title>Créer un fichier tar.gz à partir d'un fichier listant un certains nombres de fichiers</title>
        <link>http://www.posteet.com/view/1358</link>
        <description>
        <![CDATA[<pre>while read line; do
  tar -P -c -T - -f archive.tar.gz
done &lt; liste_diff.txt

Le fichier fourni en paramètre contient une liste de fichiers avec pour chacun le chemin absolu sur le serveur + nom du fichier. C’est pourquoi on rajoute l’option -P (--absolute-names) à la commande tar.

ATTENTION : Il faut laisser une ligne vide au début de fichier, sinon le premier fichier de la liste n’est pas pris en compte.

Voir aussi :
http://linuxfr.org/forums/30/21469.html</pre> <a href="http://www.posteet.com/tags/archive">[archive]</a>  <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/compression">[compression]</a>  <a href="http://www.posteet.com/tags/fichier">[fichier]</a>  <a href="http://www.posteet.com/tags/liste">[liste]</a>  <a href="http://www.posteet.com/tags/sauvegarde">[sauvegarde]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a> ]]>        </description>
        <dc:creator>cyo</dc:creator>
        <pubDate>Fri, 07 Nov 2008 14:47:21 +0000</pubDate>

            <category>archive</category>
            <category>bash</category>
            <category>compression</category>
            <category>fichier</category>
            <category>liste</category>
            <category>sauvegarde</category>
            <category>shell</category>
    
    </item>

  
    <item>
        <title>Modifier les arguments d'une commande précédente et les réutiliser</title>
        <link>http://www.posteet.com/view/1345</link>
        <description>
        <![CDATA[<pre># :h Remove a trailing file name component, leaving only the head.
# :t Remove all leading file name components, leaving the tail.
# :r Remove a trailing suffix of the form .xxx, leaving the basename.
# :e Remove all but the trailing suffix.

ls /usr/local/share/doc/3dm/3DM_help.htm
cd !$:h           # Enleve le nom de fichier, récupère uniquement le répertoire du dernier argument de la commande précédente
cat !-2$:t       # Ne garde que le nom de fichier du dernier argument de l'avant dernière commande (2eme de la fin)</pre> <a href="http://www.posteet.com/tags/arguments">[arguments]</a>  <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/cd">[cd]</a>  <a href="http://www.posteet.com/tags/commande">[commande]</a>  <a href="http://www.posteet.com/tags/directory">[directory]</a>  <a href="http://www.posteet.com/tags/filename">[filename]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a> ]]>        </description>
        <dc:creator>spirit</dc:creator>
        <pubDate>Thu, 30 Oct 2008 15:50:33 +0000</pubDate>

            <category>arguments</category>
            <category>bash</category>
            <category>cd</category>
            <category>commande</category>
            <category>directory</category>
            <category>filename</category>
            <category>shell</category>
    
    </item>

  
    <item>
        <title>Barre de progression à largeur automatique</title>
        <link>http://www.posteet.com/view/1316</link>
        <description>
        <![CDATA[<pre>#!/bin/sh

# ex :
# ~$ test.sh &quot;command1&quot; &quot;command2&quot;
# [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||] 100.00%

barre_progression ()
{
	nb_iterations=$1
	liste_length=$2
	pourcent=`echo &quot;scale=2;($nb_iterations * 100) / $liste_length&quot; | bc`
	pourcent=`printf &quot;% 3.2f&quot; &quot;$pourcent&quot;`
	
	chaine=&quot;$pourcent&quot;
	nb_etoiles=`echo &quot;scale=0;$chaine / $diviseur_barre&quot; | bc`
	etoiles=&quot;&quot;
	while test $nb_etoiles -gt 0
	do
		etoiles=&quot;${caractere_barre}${etoiles}&quot;
		nb_etoiles=`echo &quot;$nb_etoiles - 1&quot; | bc`
	done
	etoiles=`printf &quot;[%-${largeur_barre}s]&quot; &quot;$etoiles&quot;`
	pourcentage=`printf &quot;%7s&quot; &quot;$chaine&quot;`
	#echo &quot;\r${etoiles}${pourcentage}%\r\c&quot;
	printf &quot;%b%b%b&quot; &quot;\r${etoiles}&quot; &quot;${pourcentage}&quot; &quot;%\r\c&quot;
}

# INITIALISATION DE LA BARRE DE PROGRESSION
init_progress_bar ()
{
	# caractere qui sera affiche dans la barre de progression
	caractere_barre=&quot;|&quot;
	
	# detection de l'OS
	os=`uname -s | tr [a-z] [A-Z]`
	
	# recuperation de la largeur en caracteres du terminal
	if test &quot;$os&quot; = &quot;LINUX&quot;
	then
		largeur_ecran=`stty -a | grep columns | cut -d ' ' -f7 | tr -d ';'`
	elif test &quot;$os&quot; = &quot;SUNOS&quot;
	then
		largeur_ecran=`stty | grep columns | cut -d ' ' -f6 | tr -d ';'`
	else
		echo &quot;Systeme d'exploitation incompatible, programme stoppe&quot;
		exit 1
	fi
	
	# calcul de la largeur optimale de la barre de progression 
	largeur_barre=`echo &quot;$largeur_ecran - 7 - 2 - 1&quot; | bc`
	diviseur_barre=`echo &quot;scale=2;100 / $largeur_barre&quot; | bc`
	
	# protection des variables
	readonly largeur_ecran largeur_barre diviseur_barre caractere_barre
}

# gestion de la langue de l'environnement
LC_NUMERIC=C

init_progress_bar

liste_length=$#
nb_iterations=0
if test $liste_length -gt 0
then
	for i in &quot;$@&quot;
	do
		nb_iterations=`echo &quot;$nb_iterations + 1&quot; | bc`
		$i 2&gt;&amp;1 &gt;/dev/null
		barre_progression &quot;$nb_iterations&quot; &quot;$liste_length&quot;
		# sleep 1
	done
fi

echo &quot; &quot;</pre> <a href="http://www.posteet.com/tags/barre">[barre]</a>  <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/bc">[bc]</a>  <a href="http://www.posteet.com/tags/printf">[printf]</a>  <a href="http://www.posteet.com/tags/progression">[progression]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a>  <a href="http://www.posteet.com/tags/stty">[stty]</a> ]]>        </description>
        <dc:creator>spirit</dc:creator>
        <pubDate>Wed, 15 Oct 2008 13:14:46 +0000</pubDate>

            <category>barre</category>
            <category>bash</category>
            <category>bc</category>
            <category>printf</category>
            <category>progression</category>
            <category>shell</category>
            <category>stty</category>
    
    </item>

  
    <item>
        <title>Monitor a log file and execute commands based on patterns</title>
        <link>http://www.posteet.com/view/1311</link>
        <description>
        <![CDATA[<pre>#!/bin/sh
tail -fn0 /var/log/file.log | while read line ; do
        echo &quot;$line&quot; | grep &quot;pattern&quot;
        if [ $? = 0 ]
        then
                # Actions
                echo &quot;Yeah: $line&quot;
        fi
done</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/log">[log]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a>  <a href="http://www.posteet.com/tags/tail">[tail]</a>  <a href="http://www.posteet.com/tags/while">[while]</a> ]]>        </description>
        <dc:creator>spirit</dc:creator>
        <pubDate>Fri, 10 Oct 2008 13:42:42 +0000</pubDate>

            <category>bash</category>
            <category>log</category>
            <category>shell</category>
            <category>tail</category>
            <category>while</category>
    
    </item>

  
    <item>
        <title>onlogdo - monitor a log file and execute commands based on patterns</title>
        <link>http://www.posteet.com/view/1309</link>
        <description>
        <![CDATA[<pre>#!/bin/bash

# Author: Ben Wong &lt;ben@wongs.net&gt;
# Created on: &lt;2001-08-08 11:56:03 hackerb9&gt;
# Time-stamp: &lt;2002-11-20 14:13:11 bbb&gt;

# onlogdo: a hack to handle a common problem: when a certain message
# shows up in the log file, an action should be performed. E.g.: when
# a PC-card network device is inserted, it should be ifconfig'd or
# perhaps dhclient should be run. This program can do that in a fairly
# reasonable way.



### FIRST, THE HELPER FUNCTIONS ###

function showmanpage () {
    cat &lt;&lt;'EOF'
NAME

   onlogdo - monitor a log file and execute commands based on patterns


SYNOPSIS

   onlogdo &lt;logfile&gt; &lt;pattern&gt; &lt;command&gt; [ &lt;pattern&gt; &lt;command&gt; ... ]

     logfile: a file that gets appended to (e.g., /var/log/messages),
     pattern: a string (can use bash's extended pathname globbing syntax),
     command: the command to run when the previous pattern is seen.


DESCRIPTION

    Onlogdo is a hack to handle a common problem: when a certain
    message shows up in a log file, an action should be performed.
    E.g.: when a PC-card network device is inserted, it should be
    ifconfig'd or perhaps dhclient should be run. This program can do
    that in a fairly reasonable way.

    Onlogdo continuously reads lines as they are appended to a log
    file. When a line matches a given pattern, the command associated
    with that pattern is run in the background. The patterns
    recognized are standard pathname globbing (*, ?, []) plus bash's
    extended pattern matching (extglob) syntax (see bash(1)).

    The log file is reopened properly, if the log file being read is
    rotated. Also, since it blocks when waiting for new lines, onlogdo
    takes up almost no CPU time.


PATTERN MATCHING SYNTAX

    Don't worry about learning the pattern matching the first time you
    read this manual; you'll rarely need it, unless you're anal about
    being as succinct as possible. (Like the author).

    The following is an excerpt from bash's man page; see bash(1) for
    full details. In the following description, a pattern-list is a
    list of one or more patterns separated by a |. Composite patterns
    may be formed using one or more of the following sub-patterns:

       *      Matches any string, including the null string.

       ?      Matches any single character.

       [...]  Matches any one of the enclosed characters. A pair of
              characters separated by a hyphen denotes a range
              expression. If the first character following the [ is a
              ! or a ^ then any character not enclosed is matched.

      ?(pattern-list)
	     Matches zero or one occurrence of the  given patterns
      *(pattern-list)
	     Matches  zero  or  more  occurrences  of the given patterns
      +(pattern-list)
	     Matches one or more occurrences of the given patterns
      @(pattern-list)
	     Matches exactly one of the given patterns
      !(pattern-list)
	     Matches  anything  except  one  of the given patterns


EXAMPLES

    Pipelines are okay:
      onlogdo /var/log/messages '*' 'sleep 5; echo olleH | rev'

    Wildcards match filenames as usual in a command:
      onlogdo /var/log/messages 'Segfault' 'rm /*.core'

    Multiple pattern and command pairs are allowed:
      onlogdo /var/log/messages \
	    'ep0 at pcmcia' '/etc/rc.d/dhclient start' \
	    'ep0 detached'  '/etc/rc.d/dhclient stop'  \
	    'wi0 at pcmcia' '/etc/rc.d/dhclient start' \
	    'wi0 detached'  '/etc/rc.d/dhclient stop'

    Bash's extended pathname globbing to do the same as above:
      onlogdo /var/log/messages \
	    '@(ep|wi)[0-9] at pcmcia' '/etc/rc.d/dhclient start' \
	    '@(ep|wi)[0-9] detached'  '/etc/rc.d/dhclient stop'

    A useful example for NetBSD/hpcmips:
      onlogdo /var/log/messages 'hpcapm: resume' 'sleep 1; xrefresh'

    Under NetBSD/hpcmips-1.5.1, the X server screen is overwritten by the
    console on an APM resume. I put the last &quot;onlogdo&quot; example in my
    system xinitrc, so xrefresh will be run automatically. (The sleep
    is there to wait for the console to finish junking up the screen).


SEE ALSO

    tail(1), bash(1)

BUGS

    If this had been written in Perl it would have used &quot;normal&quot;
    regexp syntax instead of pathname expansion. Bash's extensions
    make the patterns as powerful as regexps, but more recondite.

    There is no (documented) way for a command to refer to specifics
    in the line that matched. E.g., if the pattern was &quot;@(ep|wi)0&quot;,
    the command wouldn't know if the line contained ep0 or wi0.

    The author has spent way too much time perfecting a kludge. No
    matter what you're using onlogdo for, there's probably a more
    &quot;correct&quot; way to do it. On the other hand, onlogdo is widely
    applicable and easy to use, so at least you won't be wasting much
    time while doing it the &quot;wrong&quot; way.

    There should be a real man page.


AUTHOR

    Ben Wong &lt;Benjamin.Wong@cc.gatech.edu&gt;


HISTORY

    Onlogdo started life as a one line kludge to work around a bug in
    the interaction between APM and the X server in NetBSD-1.5/hpcmips
    in September of 2001.

EOF
}





### USAGE AND ARGUMENT SANITY CHECKING ###

if [[ $# -lt 3 ]]; then
    showmanpage
    exit 1
fi

# Emacs's syntax highlighting doesn't handle single ticks (') properly.



# Check if -v (verbose) flag was given.
if [[ &quot;$1&quot; == &quot;-v&quot; ]]; then 
    ifverbose=echo		# Echo commands verbosely, if -v.
    shift
else
    ifverbose=:			# Usually just run a no-op.
fi


# Make sure the log file is readable.
if [[ ! -r &quot;$1&quot; ]]; then
    echo &quot;onlogdo: \&quot;$1\&quot; is not readable&quot; &gt;&amp;2
    exit 1
fi
if [[ -d &quot;$1&quot; ]]; then
    echo &quot;onlogdo: \&quot;$1\&quot; is a directory&quot; &gt;&amp;2
    exit 1
fi






### SIGNAL HANDLING AND EXIT CLEANUP ###

# Run cleanup function when shell exits.
trap cleanup EXIT


cleanup () {
    echo &quot;onlogdo: cleaning up...&quot; &gt;&amp;2
    if [[ &quot;$TAILPID&quot; ]]; then
	kill $TAILPID		# Kill the bg tail process.
    fi
    rm -f &quot;$PIPE&quot;		# Delete the named pipe.
    rmdir &quot;$PIPEDIR&quot;
    return 0
}




### MAIN ROUTINE STARTS HERE ###

# Don't expand wildcards in pattern arguments as filenames.
set -o noglob

# Use bash's extended pattern matching operators
shopt -s extglob

# Create a pipe to read the log file a line at a time; 
# Use mktemp for security.

PIPEDIR=$(mktemp -d /tmp/onlogdo.XXXXXX)
PIPE=&quot;$PIPEDIR/$(echo $1 | sed 's#^/##; s#/#.#g')&quot;	# var.log.messages
rm -f $PIPE
mknod $PIPE p
tail -Fn0 $1 &gt;$PIPE &amp;		# FSF tail: &quot;tail --retry -fn0&quot;
TAILPID=$!
exec 5&lt; $PIPE

# Copy the positional paramaters in to a variable that can be indexed.
params=(&quot;$0&quot; &quot;$@&quot;)


# Repeatedly read from the pipe, process each line.
while :; do
    while read REPLY &lt;&amp;5; do

	$ifverbose -e &quot;\nline: \&quot;$REPLY\&quot;&quot;
	for ((i=2; i&lt;$#; i+=2)); do
	    pattern=${params[$i]}
	    command=${params[$((i+1))]}
	    $ifverbose &quot;pattern: \&quot;$pattern\&quot;&quot;
	    if [[ -z &quot;${REPLY##*$pattern*}&quot; ]]; then
		$ifverbose &quot;*MATCHED*&quot;
		$ifverbose &quot;command: \&quot;$command\&quot;&quot;
		set +o noglob	# Allow pathname matching in commands
		eval $command &amp;
		set -o noglob	# No pathname expansion for patterns
	    fi
	done
    done

    # We get here whenever the pipe first blocks (returns EOF)
    sleep 1			# Don't loop too quickly
done


### MAIN ROUTINE ENDS HERE ###


# Note: if we ever get here, the cleanup() function will be called
# automatically since we're trapping on signal 0.</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/cron">[cron]</a>  <a href="http://www.posteet.com/tags/log">[log]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a>  <a href="http://www.posteet.com/tags/tail">[tail]</a> ]]>        </description>
        <dc:creator>spirit</dc:creator>
        <pubDate>Thu, 09 Oct 2008 12:09:30 +0000</pubDate>

            <category>bash</category>
            <category>cron</category>
            <category>log</category>
            <category>shell</category>
            <category>tail</category>
    
    </item>

  
    <item>
        <title>Fonctions utiles en shell</title>
        <link>http://www.posteet.com/view/1208</link>
        <description>
        <![CDATA[<pre>function apt-search (){
  apt-cache search &quot;$@&quot; | grep -v '^lib' | sort;
}

function prs (){
  ps faux | grep -v 'grep' | grep &quot;$@&quot; | sed -e 's/^\([^ ]*\) *\([0-9]*\) .*:[0-9][0-9] \(.*\)$/\1 \2 \3/g'
}</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/debian">[debian]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a>  <a href="http://www.posteet.com/tags/zsh">[zsh]</a> ]]>        </description>
        <dc:creator>yoko</dc:creator>
        <pubDate>Fri, 22 Aug 2008 00:12:13 +0000</pubDate>

            <category>bash</category>
            <category>debian</category>
            <category>shell</category>
            <category>zsh</category>
    
    </item>

  
    <item>
        <title>Appliquer les changements sur Apache après avoir fait des modifs dans php.ini</title>
        <link>http://www.posteet.com/view/1185</link>
        <description>
        <![CDATA[<pre>service httpd reload</pre> <a href="http://www.posteet.com/tags/apache">[apache]</a>  <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/linux">[linux]</a>  <a href="http://www.posteet.com/tags/php">[php]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a> ]]>        </description>
        <dc:creator>cyo</dc:creator>
        <pubDate>Mon, 11 Aug 2008 09:17:14 +0000</pubDate>

            <category>apache</category>
            <category>bash</category>
            <category>linux</category>
            <category>php</category>
            <category>shell</category>
    
    </item>

  
    <item>
        <title>Catch SIGINT and SIGTERM in a shell script (CTRL-C)</title>
        <link>http://www.posteet.com/view/1013</link>
        <description>
        <![CDATA[<pre>trap &quot;/usr/bin/mycmd; exit 255&quot; SIGINT SIGTERM</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/script">[script]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a>  <a href="http://www.posteet.com/tags/sigint">[sigint]</a>  <a href="http://www.posteet.com/tags/sigterm">[sigterm]</a>  <a href="http://www.posteet.com/tags/trap">[trap]</a> ]]>        </description>
        <dc:creator>spirit</dc:creator>
        <pubDate>Tue, 17 Jun 2008 13:41:20 +0000</pubDate>

            <category>bash</category>
            <category>script</category>
            <category>shell</category>
            <category>sigint</category>
            <category>sigterm</category>
            <category>trap</category>
    
    </item>

  
    <item>
        <title>Barre de progression à largeur automatique</title>
        <link>http://www.posteet.com/view/938</link>
        <description>
        <![CDATA[<pre>#!/bin/sh

# ex :
# ~$ test.sh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||] 100.00%

barre_progression ()
{
	nb_iterations=$1
	liste_length=$2
	pourcent=`echo &quot;scale=2;($nb_iterations * 100) / $liste_length&quot; | bc`
	pourcent=`printf &quot;% 3.2f&quot; &quot;$pourcent&quot;`
	
	chaine=&quot;$pourcent&quot;
	nb_etoiles=`echo &quot;scale=0;$chaine / $diviseur_barre&quot; | bc`
	etoiles=&quot;&quot;
	while test $nb_etoiles -gt 0
	do
		etoiles=&quot;${caractere_barre}${etoiles}&quot;
		nb_etoiles=`echo &quot;$nb_etoiles - 1&quot; | bc`
	done
	etoiles=`printf &quot;[%-${largeur_barre}s]&quot; &quot;$etoiles&quot;`
	pourcentage=`printf &quot;%7s&quot; &quot;$chaine&quot;`
	#echo &quot;\r${etoiles}${pourcentage}%\r\c&quot;
	printf &quot;%b%b%b&quot; &quot;\r${etoiles}&quot; &quot;${pourcentage}&quot; &quot;%\r\c&quot;
}

# INITIALISATION DE LA BARRE DE PROGRESSION
init_progress_bar ()
{
	# caractere qui sera affiche dans la barre de progression
	caractere_barre=&quot;|&quot;
	
	# detection de l'OS
	os=`uname -s | tr [a-z] [A-Z]`
	
	# recuperation de la largeur en caracteres du terminal
	if test &quot;$os&quot; = &quot;LINUX&quot;
	then
		largeur_ecran=`stty -a | grep columns | cut -d ' ' -f7 | tr -d ';'`
	elif test &quot;$os&quot; = &quot;SUNOS&quot;
	then
		largeur_ecran=`stty | grep columns | cut -d ' ' -f6 | tr -d ';'`
	else
		echo &quot;Systeme d'exploitation incompatible, programme stoppe&quot;
		exit 1
	fi
	
	# calcul de la largeur optimale de la barre de progression 
	largeur_barre=`echo &quot;$largeur_ecran - 7 - 2 - 1&quot; | bc`
	diviseur_barre=`echo &quot;scale=2;100 / $largeur_barre&quot; | bc`
	
	# protection des variables
	readonly largeur_ecran largeur_barre diviseur_barre caractere_barre
}

# gestion de la langue de l'environnement
LC_NUMERIC=C

init_progress_bar

liste_length=$#
nb_iterations=0
if test $liste_length -gt 0
then
	for i in $@ 
	do
		nb_iterations=`echo &quot;$nb_iterations + 1&quot; | bc`
		barre_progression &quot;$nb_iterations&quot; &quot;$liste_length&quot;
		# sleep 1
	done
fi

echo &quot; &quot;</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/bc">[bc]</a>  <a href="http://www.posteet.com/tags/printf">[printf]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a>  <a href="http://www.posteet.com/tags/stty">[stty]</a> ]]>        </description>
        <dc:creator>benoitbalon</dc:creator>
        <pubDate>Wed, 07 May 2008 12:44:58 +0000</pubDate>

            <category>bash</category>
            <category>bc</category>
            <category>printf</category>
            <category>shell</category>
            <category>stty</category>
    
    </item>

  
    <item>
        <title>Renommer des fichiers pour retirer les caractères spéciaux</title>
        <link>http://www.posteet.com/view/855</link>
        <description>
        <![CDATA[<pre>for i in `ls -1`; do cd $i; rename 's/ +/_/g' *; cd ..; done
for i in `ls -1`; do cd $i; rename &quot;s/'/-/g&quot; *; cd ..; done
for i in `ls -1`; do cd $i; rename &quot;s/[?!%]//g&quot; *; cd ..; done
for i in `ls -1`; do cd $i; rename &quot;s/[?]//g&quot; *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/[!%?]//g' *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/[àâ]/a/g' *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/[éèêë]/e/g' *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/[oöô]/o/g' *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/[ûù]/u/g' *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/[ä]/a/g' *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/[ü]/u/g' *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/[,]/-/g' *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/[(){}]/-/g' *; cd ..; done
for i in `ls -1`; do cd $i; rename 's/traeve/treve/g' *; cd ..; done</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/rename">[rename]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a> ]]>        </description>
        <dc:creator>benoitbalon</dc:creator>
        <pubDate>Tue, 01 Apr 2008 18:05:27 +0000</pubDate>

            <category>bash</category>
            <category>rename</category>
            <category>shell</category>
    
    </item>

  
    <item>
        <title>Créer un fichier compressé tar.gz sur un serveur Unix</title>
        <link>http://www.posteet.com/view/839</link>
        <description>
        <![CDATA[<pre>Crée un fichier 'sql.tar.gz' à partir de logs d’erreur 'sql-2008-03*' :
tar cvfz sql.tar.gz sql-2008-03*

puis déplace le fichier dans le répertoire supérieur :
mv sql.tar.gz ../</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/compression">[compression]</a>  <a href="http://www.posteet.com/tags/fichier">[fichier]</a>  <a href="http://www.posteet.com/tags/log">[log]</a>  <a href="http://www.posteet.com/tags/serveur">[serveur]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a>  <a href="http://www.posteet.com/tags/winscp">[winscp]</a> ]]>        </description>
        <dc:creator>cyo</dc:creator>
        <pubDate>Tue, 18 Mar 2008 09:30:22 +0000</pubDate>

            <category>bash</category>
            <category>compression</category>
            <category>fichier</category>
            <category>log</category>
            <category>serveur</category>
            <category>shell</category>
            <category>winscp</category>
    
    </item>

  
    <item>
        <title>Changer les permissions récursivement sur les dossiers uniquement</title>
        <link>http://www.posteet.com/view/812</link>
        <description>
        <![CDATA[<pre>#Pour changer les permissions récursivement sur les dossiers sans toucher aux autres fichiers :

chmod u-w $(ls -l -R | sed -n '/^d/p' | awk '{print $9 }')

#va enlever le droit d'écriture à tous les dossiers sans toucher aux autres fichiers
#utile par exemple pour appliquer le droit d'exécution seulement aux dossiers pour pouvoir les parcourir sans pour autant rendre les autres fichiers exécutables</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/linux">[linux]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a>  <a href="http://www.posteet.com/tags/unix">[unix]</a> ]]>        </description>
        <dc:creator>jon207</dc:creator>
        <pubDate>Thu, 06 Mar 2008 20:51:29 +0000</pubDate>

            <category>bash</category>
            <category>linux</category>
            <category>shell</category>
            <category>unix</category>
    
    </item>

  
    <item>
        <title>Quantième jour</title>
        <link>http://www.posteet.com/view/797</link>
        <description>
        <![CDATA[<pre>#!/bin/sh

usage=&quot;Usage : $0 -q `date +'%j'` [-y `date +'%Y'`]&quot;

# gestion de la ligne de commande
if test &quot;$#&quot; -eq 2
then
	if test &quot;$1&quot; != &quot;-q&quot;
	then
		echo $usage
		exit 1
	fi
elif test &quot;$#&quot; -eq 4
then
	if test &quot;$1&quot; != &quot;-q&quot;
	then
		echo $usage
		exit 1
	fi
	if test &quot;$3&quot; != &quot;-y&quot;
	then
		echo $usage
		exit 1
	fi
else
	echo $usage
	exit 1
fi

qte=$2

if test &quot;$4&quot; != &quot;&quot;
then
	annee_act=$4
	val_y=`expr $annee_act + 1 2&gt;&gt; /dev/null`
	if test &quot;$?&quot; != &quot;0&quot;
	then
		echo $usage
		exit 1
	fi
fi

# verification des nombres
val_q=`expr $qte + 1 2&gt;&gt; /dev/null`
if test &quot;$?&quot; != &quot;0&quot;
then
	echo $usage
	exit 1
fi

# depassements de valeurs
if test &quot;$qte&quot; -gt 366
then
	echo $usage
	exit 1
fi

if test &quot;$qte&quot; -lt 1
then
	echo $usage
	exit 1
fi

# comparaison avec le quantieme actuel
if test &quot;$4&quot; = &quot;&quot;
then
	qte_act=`date +'%j'`
	annee_act=`date +'%Y'`

	if test &quot;$qte_act&quot; -gt &quot;$qte&quot;
	then
		continue
	elif test &quot;$qte_act&quot; -lt &quot;$qte&quot;
	then
		# la date recherchee est dans l'annee passee
		annee_act=`expr $annee_act - 1`
	else
		# la date recherchee est celle d'aujourd'hui
		echo `date +'%Y-%m-%d'`
		exit 0
	fi
fi


bis=`expr $annee_act % 4`
if test &quot;$bis&quot; -gt 0
then
	fin_janvier=31
	fin_fevrier=`expr 31 + 28`
	fin_mars=`expr 31 + 28 + 31`
	fin_avril=`expr 31 + 28 + 31 + 30`
	fin_mai=`expr 31 + 28 + 31 + 30 + 31`
	fin_juin=`expr 31 + 28 + 31 + 30 + 31 + 30`
	fin_juillet=`expr 31 + 28 + 31 + 30 + 31 + 30 + 31`
	fin_aout=`expr 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31`
	fin_septembre=`expr 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30`
	fin_octobre=`expr 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31`
	fin_novembre=`expr 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30`
	#fin_decembre=`expr 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31`
else
	fin_janvier=31
	fin_fevrier=`expr 31 + 29`
	fin_mars=`expr 31 + 29 + 31`
	fin_avril=`expr 31 + 29 + 31 + 30`
	fin_mai=`expr 31 + 29 + 31 + 30 + 31`
	fin_juin=`expr 31 + 29 + 31 + 30 + 31 + 30`
	fin_juillet=`expr 31 + 29 + 31 + 30 + 31 + 30 + 31`
	fin_aout=`expr 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31`
	fin_septembre=`expr 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30`
	fin_octobre=`expr 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31`
	fin_novembre=`expr 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30`
	#fin_decembre=`expr 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31`
fi

# annee non bissextile
if test &quot;$qte&quot; -eq 366 &amp;&amp; test &quot;$bis&quot; -gt 0
then
	exit 1
fi

# detection de l'annee bissextile
if test &quot;$qte&quot; -le &quot;$fin_janvier&quot;
then
	mois=&quot;01&quot;
	jour=`expr $qte + 0`
elif test &quot;$qte&quot; -le &quot;$fin_fevrier&quot;
then
	mois=&quot;02&quot;
	jour=`expr $qte - 31`
elif test &quot;$qte&quot; -le &quot;$fin_mars&quot;
then
	mois=&quot;03&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29`&quot;
	fi
elif test &quot;$qte&quot; -le &quot;$fin_avril&quot;
then
	mois=&quot;04&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28 - 31`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29 - 31`&quot;
	fi
elif test &quot;$qte&quot; -le &quot;$fin_mai&quot;
then
	mois=&quot;05&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28 - 31 - 30`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29 - 31 - 30`&quot;
	fi
elif test &quot;$qte&quot; -le &quot;$fin_juin&quot;
then
	mois=&quot;06&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28 - 31 - 30 - 31`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29 - 31 - 30 - 31`&quot;
	fi
elif test &quot;$qte&quot; -le &quot;$fin_juillet&quot;
then
	mois=&quot;07&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28 - 31 - 30 - 31 - 30`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29 - 31 - 30 - 31 - 30`&quot;
	fi
elif test &quot;$qte&quot; -le &quot;$fin_aout&quot;
then
	mois=&quot;08&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28 - 31 - 30 - 31 - 30 - 31`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29 - 31 - 30 - 31 - 30 - 31`&quot;
	fi
elif test &quot;$qte&quot; -le &quot;$fin_septembre&quot;
then
	mois=&quot;09&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28 - 31 - 30 - 31 - 30 - 31 - 31`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29 - 31 - 30 - 31 - 30 - 31 - 31`&quot;
	fi
elif test &quot;$qte&quot; -le &quot;$fin_octobre&quot;
then
	mois=&quot;10&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28 - 31 - 30 - 31 - 30 - 31 - 31 - 30`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29 - 31 - 30 - 31 - 30 - 31 - 31 - 30`&quot;
	fi
elif test &quot;$qte&quot; -le &quot;$fin_novembre&quot;
then
	mois=&quot;11&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28 - 31 - 30 - 31 - 30 - 31 - 31 - 30 - 31`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29 - 31 - 30 - 31 - 30 - 31 - 31 - 30 - 31`&quot;
	fi
else
	mois=&quot;12&quot;
	if test &quot;$bis&quot; -gt 0
	then
		jour=&quot;`expr $qte - 31 - 28 - 31 - 30 - 31 - 30 - 31 - 31 - 30 - 31 - 30`&quot;
	else
		jour=&quot;`expr $qte - 31 - 29 - 31 - 30 - 31 - 30 - 31 - 31 - 30 - 31 - 30`&quot;
	fi
fi

# affichage de la date trouvee
if test &quot;$jour&quot; -lt 10
then
	echo &quot;${annee_act}-${mois}-0${jour}&quot;
else
	echo &quot;${annee_act}-${mois}-${jour}&quot;
fi</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/date">[date]</a>  <a href="http://www.posteet.com/tags/jour">[jour]</a>  <a href="http://www.posteet.com/tags/numero jour">[numero jour]</a>  <a href="http://www.posteet.com/tags/quantieme">[quantieme]</a>  <a href="http://www.posteet.com/tags/quantieme jour">[quantieme jour]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a> ]]>        </description>
        <dc:creator>benoitbalon</dc:creator>
        <pubDate>Thu, 28 Feb 2008 12:43:59 +0000</pubDate>

            <category>bash</category>
            <category>date</category>
            <category>jour</category>
            <category>numero jour</category>
            <category>quantieme</category>
            <category>quantieme jour</category>
            <category>shell</category>
    
    </item>

  
    <item>
        <title>WinSCP : Commande pour changer les droits et le propriétaire d'un fichier</title>
        <link>http://www.posteet.com/view/759</link>
        <description>
        <![CDATA[<pre>chown utilisateur:ftp !&amp;; chmod 0664 !&amp;</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/fichier">[fichier]</a>  <a href="http://www.posteet.com/tags/ftp">[ftp]</a>  <a href="http://www.posteet.com/tags/renommage">[renommage]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a>  <a href="http://www.posteet.com/tags/winscp">[winscp]</a> ]]>        </description>
        <dc:creator>cyo</dc:creator>
        <pubDate>Fri, 15 Feb 2008 08:54:05 +0000</pubDate>

            <category>bash</category>
            <category>fichier</category>
            <category>ftp</category>
            <category>renommage</category>
            <category>shell</category>
            <category>winscp</category>
    
    </item>

  
    <item>
        <title>Option sympa pour Grep // de la couleur dans ton grep</title>
        <link>http://www.posteet.com/view/758</link>
        <description>
        <![CDATA[<pre>grep --color EXPRESSION [FICHIER]</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/grep">[grep]</a>  <a href="http://www.posteet.com/tags/linux">[linux]</a>  <a href="http://www.posteet.com/tags/regexp">[regexp]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a> ]]>        </description>
        <dc:creator>henri</dc:creator>
        <pubDate>Fri, 15 Feb 2008 08:36:33 +0000</pubDate>

            <category>bash</category>
            <category>grep</category>
            <category>linux</category>
            <category>regexp</category>
            <category>shell</category>
    
    </item>


</channel>
</rss>
