If you want to have pico, vi or emacs editing, you can use the built-in
fc command which stands for
You can use
fc and Bash will open your last command in the defined editor, such as vi, emacs, etc. I use pico for this. You can then use multi-line editing very easily.
You can use line feeds and format to edit the command. Once you exit the editor, the command is saved to a Bash buffer and immediately executed.
In Bash, try this:
$ perl -e ''
FCEDIT=pico just sets the editor to pico. Set any editor you want. You can export that and make permanent if you wish.
perl -e '' is an empty wrapper around your new one line perl script. When you type
fc the last command is opened in the defined editor.
Now in Pico, go up to the
'' and insert your Perl script. Remember that the script is not the same as if you were saving it into a text file and is subject to the same need to be aware of how the shell is going to interpret the input between the single quotes. Mainly, you will need to escape a single quote with
In pico, insert whatever Perl code you want, (subject to the Bash interpretation of it...)
I did this:
perl -e '
print "here is a second line\n";
print "\$i=$i, \$y=$y\n\n";
Now save the file to the default name. (In pico,
Ctl+O is write out) and exit pico (Ctl+x). Bash will now echo then execute your command.
fc is documented in section 9.2 of the gnu manual HERE