Ignore:
Timestamp:
Jan 3, 2006, 4:09:12 PM (15 years ago)
Author:
bcornec
Message:

Patches from Sébastien Aperghis-Tramoni <maddingue@…>

replace several occurences of "cat .. | grep .."
or with similar commands that accept filenames as arguments.
+ some sort | uniq replaced by sort -u

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.06/mondo/mondo/common/libmondo-verify.c

    r128 r273  
    159159
    160160/*  sprintf (command,
    161        "cat %s | grep \"afio: \" | awk '{j=substr($0,8); i=index(j,\": \");printf \"/%%s\\n\",substr(j,1,i-2);}' | sort | uniq | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"/dev/.*\" > %s",
     161       "grep \"afio: \" %s | awk '{j=substr($0,8); i=index(j,\": \");printf \"/%%s\\n\",substr(j,1,i-2);}' | sort -u | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"/dev/.*\" > %s",
    162162       stderr_fname, afio_found_changes);
    163163*/
     
    165165    log_msg(1, "Now scanning log file for 'afio: ' stuff");
    166166    sprintf(command,
    167             "cat %s | grep \"afio: \" | sed 's/afio: //' | grep -vx \"/dev/.*\" >> %s",
     167            "grep \"afio: \" %s | sed 's/afio: //' | grep -vx \"/dev/.*\" >> %s",
    168168            stderr_fname, afio_found_changes);
    169169    log_msg(2, command);
     
    175175    log_msg(1, "Now scanning log file for 'star: ' stuff");
    176176    sprintf(command,
    177             "cat %s | grep \"star: \" | sed 's/star: //' | grep -vx \"/dev/.*\" >> %s",
     177            "grep \"star: \" %s | sed 's/star: //' | grep -vx \"/dev/.*\" >> %s",
    178178            stderr_fname, afio_found_changes);
    179179    log_msg(2, command);
     
    185185    afio_diffs = count_lines_in_file(afio_found_changes);
    186186    sprintf(command,
    187             "cat %s %s %s | sort | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
     187            "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
    188188            ignorefiles_fname, afio_found_changes, afio_found_changes,
    189189            changedfiles_fname);
     
    401401                    g_current_media_number, bigfile_num, slice_num);
    402402            if (bkpinfo->compression_level > 0) {
    403                 sprintf(command, "cat %s | %s -dc 2>> %s",
     403                sprintf(command, "%s -dc %s 2>> %s",
     404                        sz_exe,
    404405                        slice_fname(bigfile_num, slice_num, mountpoint,
    405                                     bkpinfo->zip_suffix), sz_exe,
     406                                    bkpinfo->zip_suffix),
    406407                        MONDO_LOGFILE);
    407408            } else {
     
    543544        sprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE);
    544545    } else {
    545         sprintf(command, "cat %s | cut -d':' -f%d | sort | uniq", outlog,
    546                 (bkpinfo->use_star) ? 1 : 2);
     546        sprintf(command, "cut -d: -f%d %s | sort -u",
     547                (bkpinfo->use_star) ? 1 : 2, outlog);
    547548        pin = popen(command, "r");
    548549        if (pin) {
     
    580581    }
    581582    /*  chdir(old_pwd); */
    582     //  sprintf (tmp, "cat %s | uniq -u >> %s", "/tmp/mondo-verify.err", MONDO_LOGFILE);
     583    //  sprintf (tmp, "uniq -u %s >> %s", "/tmp/mondo-verify.err", MONDO_LOGFILE);
    583584    //  paranoid_system (tmp);
    584585    //  unlink ("/tmp/mondo-verify.err");
     
    11481149            (int) (random() % 32767));
    11491150    sprintf(tmp,
    1150             "cat %s | grep -x \"%s:.*\" | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"dev/.*\"  > %s",
    1151             MONDO_LOGFILE, (bkpinfo->use_star) ? "star" : "afio",
     1151            "grep -x \"%s:.*\" %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"dev/.*\"  > %s",
     1152            (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE,
    11521153            changed_files_fname);
    11531154    log_msg(2, "Running command to derive list of changed files");
Note: See TracChangeset for help on using the changeset viewer.