The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

Scripts / handy tips
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 command line from within psql
Author: Dan 
Date:   04-02-08 15:57

Ever been in psql and wanted to issue a command without leaving psql? Find out how much disk space is available?

Watch this:

[student@student165 Desktop]$ psql payroll
Welcome to psql 8.3.0, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

payroll=# \!ls
Install Zend Studio Professional.desktop payroll.sql postgresql-8.3.0 postgresql-8.3.0.tar.gz Zend Studio Professional.desktop
payroll=# \!who
student pts/0 2008-02-04 05:28 (:0.0)
payroll=# \!uname -a
Linux student165.example.com 2.6.23.14-60.fc7 #1 SMP Mon Jan 14 22:15:08 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
payroll=#



In short, prefix your command with \! and it is as if you were at the command prompt.

--
Webmaster

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org