tail -n 99 test.sh | bash
tail needs to read to the end of the file before it knows if it's going to echo the first line.
F=test.sh; tail -n $(cat "$F" | wc -l) "$F" | bash
isWrapping your script in a bit more robust because it avoidsblock {} is likely the assumption thatbest option but requires changing your file is under 99 linesscripts.
F=$(mktemp) && cp test.sh $F && bash $F; rm $F;
is anotherwould be the second best option that is even more robust (can't run out of memory) and just as fast (assuming tmpfs) the disadvantage is it breaks $0 if your scripts use that.
using something like F=test.sh; tail -n $(cat "$F" | wc -l) "$F" | bash is less ideal because it has to keep the whole file in memory and breaks $0.
touching the original file should be avoided so that hard links, last modified time, and read locks, and hard links are not disturbed,. that way you can leave an editor open while running the file and rsync won't needlessly checksum the file for backups and hard links function as expected.
replacing the file on edit would work but is less robust because it's not enforceable to other scripts/users/or one might forget. And again it would break hard links.