File: stat_diff.sh

package info (click to toggle)
sra-sdk 3.0.3%2Bdfsg-6~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 165,852 kB
  • sloc: ansic: 374,775; cpp: 232,734; perl: 8,959; java: 6,253; sh: 6,032; python: 3,890; makefile: 1,046; yacc: 703; xml: 310; lex: 235
file content (22 lines) | stat: -rw-r--r-- 633 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

edit_stats()
{
    local in_file=$1
    local out_file=$2
    sed 's/<Run accession="[^"]*"/<Run accession=""/g' ${in_file}  | sed 's/<Size value="[^"]*"/<Size value=""/g' > ${out_file}
}

progname=`basename $0`
[ ! -f "$1" ] && { printf "${progname}: First file doesn't exist (error:1)\n"; exit 1; }
[ ! -f "$2" ] && { printf "${progname}: Second file doesn't exist (error:2)\n"; exit 1; }

trap '[ -f "$TMPFILE1" ] && rm "$TMPFILE1"; [ -f "$TMPFILE2" ] && rm "$TMPFILE2";' EXIT
TMPFILE1=$(mktemp) || exit 1
TMPFILE2=$(mktemp) || exit 1

edit_stats $1 $TMPFILE1
edit_stats $2 $TMPFILE2
diff $TMPFILE1 $TMPFILE2

exit $?