I found a pretty cool CSH script at work that makes a frequently used query to Postgres a little more friendly --- except that it dumps the output to the shell. This is the part of the script generating the output:

psql "select datauri from grid where datauri like '%${1}%'" | awk -F '/' '{print $3 "\t" $4 "\t" $7 "\t" $8 "\t" $9 "\t" $10 "\t" $11}'

The name of the script is "DB"

I've tried sending this output directly to a text editor to make the output easier to deal with:

$ db get stuff | emacs -nw

I only get a blank emacs ( vi, or gedit ).

Is there a way I can alter the script, or something else, to have the output sent directly to a text editor rather than just the shell?


Using vim, you can do this:

$ db get stuff | vim -

The - tells vim to read its text input from stdin.


You can run the script form withing emacs, in fact, and it would create a new buffer for its output. Just use M-! (which runs shell-command), specify the command, and then switch to the *Shell Command Output* buffer.


By vim's 'r' command, output of a command can be inserted into a specific line like :10r !db get stuff. '10r' inserts into 11th line and '!' fetches output of the following command.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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