bash debug – log all executed commands

2014-02-03 1 min read bash
Screenshot of a Bash 3.1 session demonstrating its particularities. Shows exporting a variable, alias, type, Bash’s kill, environment variables PS1, BASH_VERSION and SHELLOPTS, redirecting standard output and standard error and history expansion. A POSIX session is launched from a normal session. Finally, the POSIX session kills itself (since just “exit” would be too boring). (Photo credit: Wikipedia) Whenever I am writing a script in perl or bash, I always wish that there Continue reading

Fix typescript files generated with script command

2013-12-18 1 min read Learning Linux
Generally quite a lot of us would have used the script command. This generates the logs for the session. But the problem with the logs is that it contains a lot of un-readable characters. These characters are mostly from the color codes, and as such can be removed very easily with a single command: cat typescript | perl -pe 's/e([^[]]|[.*.*?[a-zA-Z]|].*?a)//g' | col -b > typescript-processed This assumes the input log file is named as typescript and the output is kept as typescript-processed. Continue reading

create text tables from delimited files.

2013-07-12 1 min read bash Fedora
To create simple text tables to paste in emails or to use in any other document where you want to show a table, here is something that you can use. There is a perl module which provides “tablify“. And here is how to use it: sudo yum install perl-Text-RecordParser This will install a command “tablify” that you can use in number of ways. Here is a simple example to use it. Continue reading

Vim – Why and where am I getting these errors from?

2013-05-15 1 min read Vim Tips
If you have got this question in your mind, then you are in right place. vim -V20 2>&1 |tee You can give the debugfile as any file, where you would want to log the debug messages. This will log a lot of information in the debugfile, you can open the file, once you have got the error in the main vim window. After this, you can open the debugfile and simply search for the error that you were getting. Continue reading

pigz -parallel gzip

2012-03-26 1 min read Fedora Linux
Here is a short description of pigz: pigz, which stands for parallel implementation of gzip, is a fully functional replacement for gzip that exploits multiple processors and multiple cores to the hilt when compressing data. And for the installation: sudo yum install pigz With pigz, if you don’t have many things running on your multi processor machine then you will see a significant improvement when you are gzipping the files. Continue reading

15 Linux Bash History Expansion Examples You Should Know

2012-03-02 1 min read bash
Image via Wikipedia Here is a nice link on BASH History Expansion. There are lot of examples in this page and some of them might be quite useful. But here are my list of favourites: !! This is probably the most used one by me. This will repeat the last command. And this works even in conjunction with other commands like sudo !! And the second most used one is : Continue reading

Oracle Select the top 5 queries

2012-02-27 1 min read Database
Here are one sql script that I found some time back. This will be listing the top 5 SQL queries in Oracle. SET linesize 300 SET PAGESIZE 200 select * from (select sql_text, sql_id, elapsed_time, cpu_time, user_io_wait_time from sys.v_$sqlarea order by 5 desc) where rownum < 6; quit; Related articles SQL Fiddle (thinkvitamin.com) New Oracle E-Book (arnoldit.com) All about Security – SQL Injection (tkyte.blogspot.com)
Older posts