Ticket #38150: patch-sed.diff

File patch-sed.diff, 7.2 KB (added by FlorianFranzen@…, 12 years ago)
  • scripts/duration

    diff -ur scripts/duration scripts/duration
     
    137137        # 5) start with one or more chars, then '.', then three chars, then one or more chars (for 'evt' etc.)
    138138        case5='/^.+\.[^.]{3}\.([^.-]*)+(-shifted)?$/'
    139139
    140         extension=$(basename $filename | sed -r -e "$case1 s//\1/;$case2 s//\1/;$case3 s//\1/;$case4 s//\1/;$case5 s//\1/")
     140        extension=$(basename $filename | sed -E -e "$case1 s//\1/;$case2 s//\1/;$case3 s//\1/;$case4 s//\1/;$case5 s//\1/")
    141141
    142142        # Compute duration in ms
    143143        case $extension in
  • scripts/ndm_functions

    diff -ur scripts/ndm_functions scripts/ndm_functions
     
    7878# Print error message
    7979echo_error()
    8080{
    81         indent=$(echo "$1"|sed -r 's/^([ ]*).*/\1/')
     81        indent=$(echo "$1"|sed -E 's/^([ ]*).*/\1/')
    8282        message=$(echo "$1"|sed 's/^ *//g')
    8383
    8484        echo -en "$RED" >&2
     
    8989# Print warning message
    9090echo_warning()
    9191{
    92         indent=$(echo "$1"|sed -r 's/^([ ]*).*/\1/')
     92        indent=$(echo "$1"|sed -E 's/^([ ]*).*/\1/')
    9393        message=$(echo "$1"|sed 's/^ *//g')
    9494
    9595        echo -en "$BLUE" >&2
     
    111111#                       break
    112112#               fi
    113113#       done
    114 #       indent=$(echo "$1"|sed -r 's/^([ ]*).*/\1/')
     114#       indent=$(echo "$1"|sed -E 's/^([ ]*).*/\1/')
    115115#       message=$(echo "$1"|sed 's/^ *//g')
    116116#
    117117        echo $*
     
    469469        # Start with the 'easy' ones
    470470        date=$(filename_date $dirname)
    471471        [ -z "$date" ] && return
    472         prefix=$(echo $dirname|sed -r '/(.*)-'$date'.*/!d;s//\1/')
     472        prefix=$(echo $dirname|sed -E '/(.*)-'$date'.*/!d;s//\1/')
    473473
    474474        # Deal with the 'hard' end of the filename
    475475        description=${dirname#$prefix-$date}
    476476        if [ -z "$suffix" ] && ! $no_suffix
    477477        then
    478                 suffix=$(echo $description|sed -r '/.*-(.*)/!d;s//\1/')
     478                suffix=$(echo $description|sed -E '/.*-(.*)/!d;s//\1/')
    479479        fi
    480480        description=${description%$suffix}
    481481        description=${description%-}
     
    535535        # Start with the 'easy' ones
    536536        date=$(filename_date $filename)
    537537        [ -z "$date" ] && return
    538         prefix=$(echo $filename|sed -r '/(.*)-'$date'.*/!d;s//\1/')
    539         nn=$(echo $filename|sed -r '/'$prefix'-'$date'-([0-9]{2})-.*/!d;s//\1/')
    540         extension=$(echo $filename|sed -r '/.*[.](.*)/!d;s//\1/')
     538        prefix=$(echo $filename|sed -E '/(.*)-'$date'.*/!d;s//\1/')
     539        nn=$(echo $filename|sed -E '/'$prefix'-'$date'-([0-9]{2})-.*/!d;s//\1/')
     540        extension=$(echo $filename|sed -E '/.*[.](.*)/!d;s//\1/')
    541541        [ ! -z "$extension" ] && p_extension=.$extension
    542542
    543543        # Special case: evt files end in .ccc.evt where 'c' is any character
    544544        if [ "$extension" == "evt" ]
    545545        then
    546                 evt=$(echo $filename|sed -r '/.*[.](.{3})[.]'$extension'/!d;s//\1/')
     546                evt=$(echo $filename|sed -E '/.*[.](.{3})[.]'$extension'/!d;s//\1/')
    547547                [ ! -z "$evt" ] && p_evt=.$evt
    548548        fi
    549549
    550550        # Deal with the 'hard' end of the filename
    551         end=$(echo $filename|sed -r '/'$prefix'-'$date'-'$nn'-(.*)'$p_evt$p_extension'/!d;s//\1/')
    552         NNN=$(echo $end|sed -r '/.*-([0-9]+).*/!d;s//\1/')
     551        end=$(echo $filename|sed -E '/'$prefix'-'$date'-'$nn'-(.*)'$p_evt$p_extension'/!d;s//\1/')
     552        NNN=$(echo $end|sed -E '/.*-([0-9]+).*/!d;s//\1/')
    553553        description=${end%-$NNN}
    554554        description=${description%$p_evt}
    555555        if [ -z "$suffix" ] && ! $no_suffix
    556556        then
    557                 suffix=$(echo $description|sed -r '/.*-(.*)/!d;s//\1/')
     557                suffix=$(echo $description|sed -E '/.*-(.*)/!d;s//\1/')
    558558        fi
    559559        description=${description%-$suffix}
    560560
     
    585585        local filename=$1
    586586
    587587        # Case 1: date is specified as YYYYMMDD in the file name
    588         d=$(echo $filename | sed -r '/.*([0-9]{8}).*/!d;s//\1/')
     588        d=$(echo $filename | sed -E '/.*([0-9]{8}).*/!d;s//\1/')
    589589        # Case 2: date is specified as YYYY-MM-DD in the file name
    590         [ -z "$d" ] && d=$(echo $filename | sed -r '/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/!d; s//\1/')
     590        [ -z "$d" ] && d=$(echo $filename | sed -E '/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/!d; s//\1/')
    591591
    592592        echo $d
    593593}
     
    601601        local d
    602602
    603603        # Case 1: date is specified as YYYYMMDD in the file name
    604         d=$(echo $1 | sed -r '/.*([0-9]{4})([0-9]{2})([0-9]{2}).*/!d;s//\1-\2-\3/')
     604        d=$(echo $1 | sed -E '/.*([0-9]{4})([0-9]{2})([0-9]{2}).*/!d;s//\1-\2-\3/')
    605605        # Case 2: date is specified as YYYY-MM-DD in the file name
    606         [ -z "$d" ] && d=$(echo $1 | sed -r '/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/!d; s//\1/')
     606        [ -z "$d" ] && d=$(echo $1 | sed -E '/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/!d; s//\1/')
    607607
    608608        echo $d
    609609}
     
    705705        for (( i=0;i<$n;i++ ))
    706706        do
    707707                suffix=$(get_suffix $i ${suffixes[*]})
    708                 file_list="$file_list $(ls ../$directory-$suffix|cut -d/ -f 3|sed -r 's/(.*)-'$suffix'.*/\1/g')"
     708                file_list="$file_list $(ls ../$directory-$suffix|cut -d/ -f 3|sed -E 's/(.*)-'$suffix'.*/\1/g')"
    709709        done
    710710
    711711        # List all sessions
  • scripts/ndm_recolorchannels

    diff -ur scripts/ndm_recolorchannels scripts/ndm_recolorchannels
     
    7777        command='/'$s'/N;/'$s'/N;/'$s'/s/#....../#'${color[$i]}'/g;'$command
    7878done
    7979
    80 [ ! -z "$command" ] && sed -i -e $command $file
     80[ ! -z "$command" ] && sed -i '' -e $command $file
  • scripts/ndm_start

    diff -ur scripts/ndm_start scripts/ndm_start
     
    267267                then
    268268                        echo_warning "directory name '$directory' does not seem to contain a date"
    269269                else
    270                         sed -i 's/<date>.*<\/date>/<date>'$d'<\/date>/' $template.xml
     270                        sed -i '' 's/<date>.*<\/date>/<date>'$d'<\/date>/' $template.xml
    271271                fi
    272272                if [ -f $directory.xml ] && ! diff -I '<date>' -q $template.xml $directory.xml >/dev/null
    273273                then
  • scripts/ndm_transcodevideo

    diff -ur scripts/ndm_transcodevideo scripts/ndm_transcodevideo
     
    5656# // Process
    5757# ////////////////////////////////////////////////////////////////////////////////////////////////
    5858
    59 input_codec=$(ffmpeg -i $video_file 2>&1|grep "Video:"|sed -r 's/.*Video: ([0-9A-Za-z]{4}).*/\1/')
     59input_codec=$(ffmpeg -i $video_file 2>&1|grep "Video:"|sed -E 's/.*Video: ([0-9A-Za-z]{4}).*/\1/')
    6060if [ "$input_codec" == "IV50" ] && [ "$(uname -m)" == "x86_64" ]
    6161then
    6262        # Intel Indeo V5.0 (IV50) is a proprietary codec used by Spike2, that can be decoded only by the 32bit version
  • scripts/process_renameevents_SPWR

    diff -ur scripts/process_renameevents_SPWR scripts/process_renameevents_SPWR
     
    3030[ -z "$(ls $session*evt 2> /dev/null)" ] && exit $NO_ERROR
    3131for eventfile in $session*evt
    3232do
    33         sed -i \
     33        sed -i '' \
    3434                -e 's/[[:space:]]0$/\tStimulation/' \
    3535                -e 's/[[:space:]]1$/\tRipple Left/' \
    3636                -e 's/[[:space:]]2$/\tRipple Right/' \
  • scripts/process_renameevents_TMaze

    diff -ur scripts/process_renameevents_TMaze scripts/process_renameevents_TMaze
     
    2727[ -z "$(ls $session*evt 2> /dev/null)" ] && exit $NO_ERROR
    2828for eventfile in $session*evt
    2929do
    30         sed -i \
     30        sed -i '' \
    3131                -e 's/[[:space:]]0$/\tTurn left/' \
    3232                -e 's/[[:space:]]1$/\tTurn right/' \
    3333                -e 's/[[:space:]]100$/\tTrial start/' \