Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

2007/08/27

rename files


    for i in 2mD* ; do
    mv $i test-"$i";
    done;


    for i in P* ; do
    new=`echo $i | sed s/"Picture "/course-Picture_/g`;
    mv "$i" $new;
    done;


File re-namer (http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-12.html#ss12.3)

File re-namer (http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-12.html#ss12.4)

2007/06/03

shell: expresiones aritmeticas

Hay dos posibilidades, utilizar el operador aritmetico $(()):


    i=1
    i=$(($i+1))
    echo $i


o bien el comando shell 'expr':


    i=1
    i=`expr $i + 1`
    echo $i


AH

noclobber / shell options / overwrite files


    set -o noclobber
    set -C (es equivalente al anterior)


overwrite: NOT ALLOWED

    % set -C
    % ll > 1
    bash: 1: cannot overwrite existing file
    % set | grep SHELLOPTS
    SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:moni


overwrite: ALLOWED

    % set +C
    % ll > 1
    %
    % set | grep SHELLOPTS
    SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:moni