Saturday, April 17, 2010

Vi

@Case Insensitive Search: There it is, I've often wanted to search words with cse off in "/" search.
If \c appears anywhere in a pattern the whole pattern is assumed to be case insensitive(ignore case). It overrides usual settings like smartcase or ignore case e.g.
/\cname or /name\c
or best option is work with smart case option on :set scs
'smartcase' can be set to ignore case when the pattern contains lowercase
letters only.

Take a look at :help ignorecase in vim for more info.
I use the ignorecase and smartcase settings as default, and they work great for me. Any search with an uppercase character becomes a case sensitive search.

:set ic
If the 'ignorecase' option is on, the case of normal letters is ignored.

*/\c* */\C*

Thursday, April 15, 2010

lsof

Today's command lsof ========================== next command nl

LiSt Open Files.
Using Options
-c
Show us what files are opened by processes whose names starts by ____(bash,iTunes,S, . . . )
     lsof -c S
     lsof -c bash
     lsof -c iTunes
-t
list only Process Id's (PID) so ls -t list all unique process id running on system which is using some file.
+p
Show us what files are using the process whose PID is 318:
     lsof +p 318

+D
Search for all opened instances of directory ~/Project and all the files and directories it contains:
     lsof +D ~/Project

-i
Show all connections
lsof -i

Show only TCP connections
lsof -iTCP


Show only UDP connections
lsof -iUDP

-i :port shows all networking related to a given port
lsof -i :22

lsof -i| grep LISTEN
lsof -i| grep ESTABLISHED
Grepping for "ESTABLISHED" or "LISTEN" listening connections

Use -a option to combine search terms.
lsof -a -u nandan -i
"show me everything running for user nandan and using some kind of connection"

Use it to kill processes
kill -9 `lsof -a -u nandan -c VLC -t`