I was very surprised how pure the Oracle’s command line utility SQL*Plus. Comparing with mysql it lack history, completion and doesn’t allow even edit query. To fix that the utility rlwrap can be used. I installed it via yum under Fedora 11 and run like that:
rlwrap sqlplus db_user@db
To have auto-complete feature you should find file SQL.dict somewhere (drop the comment, please, if you know the place). It contains SQL keywords, functions and commands. The command to run SQL*Plus will be following in that case:
rlwrap -b “” -f $HOME/sql.dict sqlplus db_user@db
To make our life easier we can create an alias in the .bash_profile or .profile:
alias mysqlplus=’rlwrap -b “” -f $HOME/sql.dict sqlplus’
There is an another interesting improvement for Linux users – using VIM as default editor of SQL*Plus. I didn’t try it practically yet.
[via Oracle Online]
I like Perl and I use it every day. It’s cool to make a simple scripts in one line to do some routine work. For example, my first Perl oneliner formats Apache log to be easy readable. Here is another good example of Perl onliner (it isn’t my actually). It makes a recursive search and replacement:
Perl -p -i -e ‘s/oldstring/newstring/g’ `grep -ril oldstring *`
[via About: Perl]
I came across a brief howto “Implementing with PHP: Standalone Scripts”. I’m Perl guy but I have to use PHP in command line to perform some SugarCRM backgound tasks. I found useful the part about parsing command-line arguments with Console/Getopt.php. It may do administration tasks much easier.
Recently I’ve had a little problem. I’ve needed to create an archive from some source directories but I’ve not needed to add in the archive some subdirectorives. I’ve made a quick search in Google and found an article “Telling tar Which Files to Exclude or Include”. Here is a short example:
$ find videoguide/ ! -type d -print | egrep ‘/,|%$|~$|.jpg$|.gif$|.png$’ > /tmp/exclude_files
That command forms a list of excluded files and store it into temporary file.
$ tar vcfX ~/projects/arc/vg-19012004.tar /tmp/exclude_files
will remove files which listed into excluded_files from archive.
Updated: There is a more simple way to exclude file/dir from the archive. You can define a pattern in the command line instead of creation a file. Let’s image that we need to exclude Subversion directories from the archive:
tar vzcf my-project.tar.gz –exclude=’.svn’ ProjectDir
Note: you should always wrap the pattern by quotes!