Category Archives: Misc - Page 9

Open multiple files in individual tabs in vim using script

I have always wanted one program to open to access all important (for me) files in a system. This can for instance be http.conf, passwd, groups and so on. Using tabs in vim, the -p option (from version 7 and above) and a small script can make vim into a nice little admin console:

I call my script ‘configs’ and it looks like this (put it in your PATH for easy access):

#!/bin/bash
sudo vim -p /etc/hosts /private/etc/php.ini /etc/httpd.conf

Too move between tabs in command mode:

gt - next tab
gT - previous tab

Too move between tabs in insert mode (and also in command mode):

CTRL + PgUp - next tab
CTRL + PgDown - previous tab  

Sending the same message to two or more queues using the Q program

During development of integration solutions I often find it useful to send the same message too two or more different queues. Doing this with the Q-program (ma01) is really easy since it can do this natively

q -m MYQMGR -I MYINQ -o MYOUTQ1 -o MYOUTQ2

This will move all messages from MYINQ and put them on both MYOUTQ1 and MYOUTQ2 on q manager MYQMGR. The trick is to use multiple -o options. The Q program will put the messages on all the queues listed.

To copy instead of move change the -I to -i like this:

q -m MYQMGR -i MYINQ -o MYOUTQ1 -o MYOUTQ2

This will leave the messages on MYINQ and only copy them to MYOUTQ1 and MYOUTQ2

“dos2unix” function for multiple files using Perl

Changing line endings from DOS to UINX for a single file is easily done with the dos2unix command in most *NIX systems. Doing the same on a whole folder of files is however a little more tricky. To solve that problem I stumbled across this solution made in Perl:

perl -pi -e 's/\cM$//' *

Just run it from inside the folder which files you want to convert and “Bob’s your Uncle” 😉