I know you, but you don't know me
Bash - 32 characters

Script A - 16 characters

cmp -s b&amp;&amp;echo 1


Script B - 16 characters

cmp -s a||echo 1


Usage

$&gt; echo "foo" | ./a
$&gt; cat b | ./a
1
$&gt; echo "foo" ./b
foo ./b
$&gt; cat a | ./b