How to copy command line commands into a text file...
Hi,
Generally many times I test a code (either bash or awk) on command line. Sometimes it is very long command. My problem is how to copy this command line command into a vi editor? Presently i am doing like this.. $echo "my command" > somefile. Here what is happening the command is copied but it is missing double quotes in the command. For example. My command is: $awk '{sum+=$1}END{printf "%12.2f\n",sum}' input if i write the above command using echo into my editor...the double quotes in the printf function are missing. So how can i copy my commandline command into vi as it is? |
Select the text with the mouse, run vi and paste the text with the middle mouse button. This assumes you have gpm running, but usually you do.
|
Add this to your .bashrc
Code:
alias elc='history -a ; tail -2 $HISTFILE | head -1' Code:
$ elc > filename |
Maybe output redirection would work for you.
Code:
Output redirection: |
Hi,
If you use the 'gpm' as suggested then you can highlight the command line then with your open 'vi' in insert you can click the right mouse button to place the buffer at the cursor point. You do know that the command line has a buffer that you can scroll through and edit via the arrow keys along with the keyboard edit keys. You can utilize these with 'gpm' to enhance your session. |
Hi arizona....
your code is not working...its giving a # followed by some digits as ouput... what must be the wrong ? I am using ubuntu8.1 example: #1240736419 |
Dunno. Works for me. Did you remember to source your .bashrc or log out and in again after making the change to your .bashrc?
|
All times are GMT -5. The time now is 09:57 PM. |