Category Archives: shell tips

sqlplus, utility scripts

I would like to use sqlplus in development projects, and I would like it to be easy to use. First off, I want command-history and tab-completion. The easiest approach is to use rlwrap which uses the GNU readline library as … Continue reading

Posted in oracle, shell tips

screen and screenrc

I would like to use GNU screen as a window manager. By default screen seems like little more than a persistent shell (that you can resume even after logging out). By itself, this is incredibly useful if you wish to … Continue reading

Posted in bash, shell tips

sqlplus pagesize and linesize

I would like sqlplus output to be more readable. Fortunately, you can adjust the pagesize and linesize variables on the fly, e.g., foo_owner@FOO> set pagesize 50000 foo_owner@FOO> set linesize 120 You can set pagesize to 0, which is very useful … Continue reading

Posted in oracle, shell tips

sqlplus command prompt (sqlprompt)

I would like to change the sqlplus command-prompt to something more useful than SQL> You can modify the sqlprompt variable as follows, SQL> SQL> set sqlprompt "_USER'@'_CONNECT_IDENTIFIER> " FOO_OWNER@FOO> You can also use variables such as _PRIVILEGE and _DATE, although … Continue reading

Posted in oracle, shell tips

reverse ssh tunnel

I would like ssh access to a protected host that is not directly accessible on the Internet but does have outbound access. This is a common scenario in corporate networks that often require a vpn for remote access; but in … Continue reading

Posted in shell tips, ssh

ssh agent across multiple hosts

I would like secure single-sign-in across multiple hosts. An easy way to do this is with ssh-agent, however, ssh-agent is a bit limited. For example, the normal use of ssh-agent looks like this, $ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-stSwW11394/agent.11394; export SSH_AUTH_SOCK; SSH_AGENT_PID=11395; export … Continue reading

Posted in shell tips, ssh

python, unique files by content

I would like to retrieve a list of unique files by content rather than by filename. That is, if spam.txt and eggs.txt both contained the same contents I want only one of them to return. A very simple approach is … Continue reading

Posted in python, shell tips

mysqldump, tips and tricks

I want to backup a mysql database. The easiest approach is using mysqldump with its default options, i.e., # mysqldump -u user -h host -ppass db > backup.sql This will dump the full DDL and DML needed to re-create the … Continue reading

Posted in mysql, shell tips

tail -F

I would like to follow an error log as errors are written. The GNU tail command support a --follow option that outputs data as a file grows. There's also a --retry option that will keep trying to access a file … Continue reading

Posted in shell tips

nohup &

I would like to run a script in the background and to keep running even after I log out. To run a command or script in the background use an ampersand, e.g., # ./ & This is equivalent to suspending … Continue reading

Posted in bash, shell tips

smiley shell prompt, or frown

I've been using the following command prompt for years server ~/dir :) whoami victor server ~/dir :) badcommand -bash: badcommand: command not found server ~/dir :( echo sorry sorry server ~/dir :) It's a smiley emoticon, but only when the … Continue reading

Posted in bash, shell tips

recursive grep

I am trying to search through all files in a directory tree, perhaps to find a specific function declaration. Ideally I want the exact files and line numbers of every search match. A modern GNU grep contains a "-r" recursive … Continue reading

Posted in shell tips