by sp332 · 12y ago · 0 comments
cat /proc/53165/exe > /tmp/oldBash
I would have reached for 'cp /proc/53165/exe /tmp/oldBash', instead of using cat. Is there an advantage to using cat here, or is it just the same?However, reaching for one way of doing things when the justification for the other way of doing things is because you've seen them done that way more, is not really good justification. So maybe that blurry brain is a good brain sometimes, in retrospect.
As to 'cp' vs 'cat': neither is a builtin, so they both are risky. What if you also accidentally did a rm -rf / on that system?
Mac OS X doesn't have a /proc filesystem, so I cannot test it, but from reading the man page
read -N 1000000000 /proc/53165/exe $bash
should read all of bash into $bash, if it isn't ridiculously large, and echo -nE $bash > myBash
should then complete the copy. read -N 1000000000 /proc/53165/exe $bash
That shouldn't work, due to NUL bytes.