I asked chatGPT for a script:

Write a shell script that processes a file called index.md the file contains lines that start '##' and contain a date. It also containes lines that contain "weight" and a weight in kg. Every time the script finds a weight it should output it with the date that came BEFORE it.

It produced someone that wasn't what I wanted so I included:

The script should output the date, a ':' and then the weight in kg

and then

allow both 'weight' and 'Weight'

and then

the input.md file is at ../index.md

and then some more lines until it worked. Now I want to include the prompt as a comment in the script in case I want to regenerate later with some changes. But I really want one prompt.

How can I ask chatGPT to give me a single prompt that produces only the last output of the session. Sometimes there are 20 commands in a conversation and it's a minor pain point to copy paste them all in to the code, and then back out again later.


1 Answer 1


I find it most effective to realize that working with ChatGPT is a conversation. So, your experience is very normal: we often do not know all the details that are query needs until we have this kind of back-and-forth; ChatGPT's initial responses show us that we were not sufficiently clear.

Whenever I have this kind of situation, I complete the loop with one final prompt that goes something like this.

Based on this conversation, give me a single prompt that I can give you (ChatGPT) next time that will give me the final results.

Then ChatGPT generates a clear, succinct prompt. You should always test the new prompt by starting a new conversation and then trying the prompt it gave you. This almost always works for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.