czwartek, 13 marca 2014

OMG ... vim ... and spaces ...

Simple shot.

File, in file some columns, where one line looks like this (some part from
psql -l -U username)

 niet            | niet    | UTF8
 postgres    | postgres | UTF8
 template0  | postgres | UTF8
 template1  | postgres | UTF8
 testowa     | postgres | UTF8
 testowa1   | mzdw     | UTF8
 testowisko | postgres | UTF8

I need only 1st word from line.

Commands
:1 (move to 1st line)
V (select line)
G (move to end of test and also keep selected)

Then press : (will see this->     :'<,'>   )

Type: s/ .*// and press Enter

And all go off ;)
Why ?

Thats why, because 1st character is a space before 'niet, and other dbnames'.

Press u (it will undo changes).

Now, let be a little smart ;) ?????

:1
V
G
:'<,'>s/^ // | '<,'>s/ .*//g

Tap enter and again enter :D


Uff ;)

New parts for hobby

New parts for hobby

środa, 12 marca 2014

For example, there is two pids, 12344 and 23444 which was 1st?

Last time at job interview I was asked about pids on Linux system.

For example, there is two pids, 12344 and 23444 which was 1st?

At 1st shot pids start from 1 for init then pid grow up, usually per 1 ;)
but nowadays Linux kernel has 'magic' option, which 'mix' pid.
They are not counted step by step ;)

There is some free spaces between pid numbers, some app start, then stop,
kernel works and thinks which pid give.


[root@mail ~]# ps -eo pid,lstart,cmd
  PID                  STARTED CMD
    1 Fri Mar  7 09:38:00 2014 init [3] 
    2 Fri Mar  7 09:38:00 2014 [kthreadd]
    3 Fri Mar  7 09:38:00 2014 [ksoftirqd/0]
    5 Fri Mar  7 09:38:00 2014 [kworker/0:0H]
------
 3942 Fri Mar  7 09:41:47 2014 /usr/sbin/httpd -f /etc/httpd/apache.conf
 9727 Mon Mar 10 12:49:14 2014 /sbin/mingetty --noclear tty1
10527 Fri Mar  7 11:36:32 2014 /usr/sbin/sshd

-------
17901 Wed Mar 12 12:14:45 2014 dovecot/pop3-login
17903 Wed Mar 12 12:14:58 2014 ps -eo pid,lstart,cmd
18252 Sat Mar  8 01:40:34 2014 dovecot/auth
22125 Mon Mar 10 05:02:06 2014 /usr/sbin/fcgi- -f /etc/httpd/apache.conf


Whatever ...