<div dir="ltr"><div class="gmail_extra"><div class="gmail_extra">zx2c4@thinkpad ~ $ cat replacement-test.sh </div><div class="gmail_extra">#!/bin/sh</div><div class="gmail_extra"><br></div><div class="gmail_extra">password="$(pwgen -s -y 900 1)"</div>
<div class="gmail_extra">oldfile=$'this is\nthe old file\nwith various\nnew lines\nand whatnot\n'</div><div class="gmail_extra">[[ $password == "$(sed $'1c \\\n'"$(sed 's/[\/&]/\\&/g' <<<"$password")"$'\n' <<<"$oldfile" | head -n 1)" ]] && echo "It works!"</div>
<div class="gmail_extra">zx2c4@thinkpad ~ $ ./replacement-test.sh </div><div class="gmail_extra">It works!</div></div></div>