#!/bin/sh
#originally yoinked from #awk
#remove the trailing /'s
#while test $# -gt 0; do
case $1 in
--command | --cmd | --c | -c | -cmd )
shift
CMD=$1
# printf "%q " $1
# CMD="$VAR"
shift
;;
esac
one=$1
two=$2
echo "----------"
printf -v VAR "%q " $CMD
echo "----------"
dir1="${one/%\//}"
dir2="${two/%\//}"
echo "cmd=$CMD"
echo "vvv=$VAR"
echo "dir1=$dir1"
echo "dir2=$dir2"
TEMPDIR=${HOME}/tmp
FOO=$(cd ${dir1} && $CMD)
BAR=$(cd ${dir2} && $CMD)
seperator=":===============:"
echo "$FOO" > ${TEMPDIR}/foo.txt
echo "$BAR" > ${TEMPDIR}/bar.txt
#/* /^$seperator$/ {dir++; next}; */
echo -en "$seperator\n$FOO\n$seperator\n$BAR\n" > ${TEMPDIR}/foobar.txt
echo -en "$seperator\n$FOO\n$seperator\n$BAR\n" | awk -v "dir1_n=$dir1" -v "dir2_n=$dir2" -v "seperator=$seperator" '
$0 == seperator {dir++; next};
/^$/ {next};
1==dir{dir1[$0]++; next};
2==dir{dir2[$0]++; next};
END{
fmt = "%s\t%s\n";
printf fmt, dir1_n "/:", dir2_n "/:";
for (i in dir1) if (i in dir2) {delete dir1[i]; delete dir2[i]; printf fmt, i, i}
else {printf fmt, i, ""};
for (i in dir2) printf fmt, "", i}'
No comments:
Post a Comment