2014년 5월 19일 월요일

Linux tips

1. VI, VIM tips

(1)Case Insensitive search in vi

 If you want to ignore case for one specific pattern, you can do this by
prepending the "\c" string. Using "\C" will make the pattern to match case.

(2) Change characters into all lower or upper capitals.

 ":%s/[A-Z]/\L&/g" or  ":%s/[a-z]/\U&/g" 


(3)Copy/Paste to/from clipboard.

: Check 'vim --version' if it has '+clipboard' .  If it is not, one may install vim-gnome or vim+gtk.
  One can copy to clipboard after selecting in visual mode by "+y 
  (With shift key, press " and press + , then release shift key and press y ). 


 2. SED tips


(1) search strings with special character :  put \ in front of any special character
(2) wild character : use .* instead *
   Ex:    sed ‘s/\[.*\]/xxx/’    replaces string ‘[......]’ to ‘xxx’


 Removing ^M from file: 



 1. To remove the ^M character, in ViM, write the following in the command mode and press :w to save the changes:

 :set fileformat=unix

 2. Or, type this script in ViM, in the command mode and type :w to save the changes:
   ^V^M gives ^M character in the screen
:1,$s/^V^M//g

 3. With sed:

 $ sed 's/^M//g' filename > newfilename

 4. With Dos2Unix:

 $ dos2unix filename newfilename

 5. With col:

 $ cat filename | col -b > newfilename

 use Internet Explorer (IE) as an FTP client.
ftp://[id]@[ftpaddress]:{port} or ftp://[ftpaddress]:{port}


 change multiple file names


rename "s/ *//g" *.mp3


 column editing:


Notepad++, Visual Studio, and some others: Alt + drag.
vim: Ctrl + v 
Netbeans 7.1 can select columns (Rectangular Selection) with Ctrl + shift + R 
Since Eclipse 3.5, you just need to type Alt+Shift+A
In Kate toggle Ctrl + shift + B


 Delete many files except several:


        [wild cards][Control+shift+x, *]   (즉 ^X*) 
        shows all visible files match. Then remove those from the list to keep.


VIM editor encryption:

1. edit .vimrc file and add 'set cm=blowfish'. This gives better encryption.
2. Set encrption password by ':X'
3. make change and save file. Now the file is encrypted.
4. To remove ecncryption, set blank key by 'set key=' .


        

댓글 없음:

댓글 쓰기