
Photo by Torsten Dederichs on Unsplash
I tried to use the in-house version of GPT bot at work to "save myself time" at the Linux prompt. What followed was a comedy of errors:
Prompt:
linux command to take a text file and delete any line that has the next to last character being "d"
Answer THAT DIDN'T WORK (minus the useless pleasantries that it spits out):
sed '/.\{2\}d.$/d' input.txt > output.txt
Told it that it didn't work. It did the regular apologies and spat this:
sed '/d.$/d' input.txt > output.txt
Still didn't freaking work. It uselessly apologized and spat this:
awk '{ if (length($0) < 2 || substr($0, length($0)-1, 1) != "d") print }' input.txt > output.txt
...which DIDN'T WORK, so after apologizing again it gave this:
awk 'length($0) > 1 && substr($0, length($0)-1, 1) != "d"' input.txt > output.txt
AND IT DIDN'T WORK, the post-apology output being:
sed -n '/.\{1\}d.$/!p' input.txt > output.txt
(it did all those verbose bullshit like "let's try this other approach", "address this issue by" etc etc etc which I left out, otherwise this post would be 5x as long)
Of course that didn't work, the next useless non-answer after I typed "you failed. I give up" being:
awk 'length($0) < 2 || substr($0, length($0)-1, 1) != "d"' input.txt > output.txt
"no. just. no."
sed '/.\{1\}d.$/d' input.txt > output.txt
"nooooooooooooooooooooooooooooooooooooooooo", I typed.
"I apologize for the frustration. Let's try to solve this problem with a fresh approach. Here's a step-by-step explanation and a command that should work:" (which, by the way, it did so BEFORE, so not quite holding my breath when I scrolled down and saw...)
awk 'length($0) < 2 || substr($0, length($0)-1, 1) != "d"' input.txt > output.txt
(with a buncha steps, which didn't matter one whit because)
IT STILL DIDN'T CLUCKING WORK.
If anyone tells me to “prompt engineer,” I’d tell the person to kindly SLAG OFF because in that time I could’ve just opened the darned text file and quickly edited it MYSELF, multiple times over.