Skip to content

Instantly share code, notes, and snippets.

@nnabeyang
Created December 3, 2017 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nnabeyang/0b310f78d12aa14887d834ceb4bd4903 to your computer and use it in GitHub Desktop.
Save nnabeyang/0b310f78d12aa14887d834ceb4bd4903 to your computer and use it in GitHub Desktop.
ファイルの最後にヌルバイトを追加する。追加後と追加前で差異が無いかチェックする
#!/bin/bash
ls -l $1 | awk '{print $5,$10}'|
while read n f
do
if [ "$f" != "" ]; then
xxd -p "$2/$f" | fold -w2 | head -n $n | diff -u "$3/$f" -
fi
done
#!/bin/bash -xe
SRC=$1
DEST=$2
SIZE=$3 #1472
[ -d txt ] && rm -rf txt
[ -d "$DEST" ] && rm -rf "$DEST"
mkdir txt
mkdir "$DEST"
echo "print '0' * (${SIZE} * 2)" | python > null.txt
./mkdata.bash "$SRC" ${SIZE} ${DEST}
./txt.bash "$SRC"
./diff.bash $SRC $DEST txt
#!/bin/bash -xe
[ -d $1 ] && exit 1
mkdir $1
seq 1 $2 |
while read n
do
if [ "$n" != "" ]; then
cp $3 "$1/$n.bin"
fi
done
#!/bin/bash
append-null() {
xxd -p "$1/$2" | cat - null.txt | xargs | sed 's/ //g'|awk "{print substr(\$1, 1, 2 * $3)}" | xxd -r -p
}
ls -l $1 | awk '{print $5,$10}' |
while read n f
do
if [ "$f" != "" ]; then
append-null $1 $f $2 > "$3/$f"
fi
done
#!/bin/bash
ls -l $1 | awk '{print $10}' |
while read f
do
if [ "$f" != "" ]; then
xxd -p "$1/$f" | fold -w2 > "txt/$f"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment