Preserving newlines when writing loops on the command line in bash

Dear All,

I have a question that's been difficult to get an answer to.

I often write command line loops, e.g. find files, print name, grep for term, apply sed, etc

I use both zsh and bash.

When I write a loop e.g.

for line in `more myfile.txt`
> do
> echo $line
> done

but then cycle back through the history, in Bash it is re-formatted as:

for line in `more myfile.txt`; do echo $line; done

In zsh, it is not re-formatted, it is displayed on separate lines, just as I input it.

I much prefer it being displayed line by line (i.e. the zsh way) rather than on a single line with semicolon separation.

Do you know if/how I can force bash to represent this line by line?

Thanks alot

Regards

JohnK1

Regards,
Alister

Alister,

That's great, thanks very much.

Regards

JohnK1