Wednesday, August 31, 2011

Vim search string case insensitive

Vim search string case insensitive

If \c appears anywhere in a pattern the whole pattern is assumed to be case insensitive. So to search for the string "root" while ignoring case you'd use




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.

\c is good to know when your working on other people's stations.

To ignore case in the searches, enter the following command:
:set ignorecase
:set ic

To turn on smartcase:
:set scs

This command can be abbreviated :set ic. To turn off this feature, use:

:set noignorecase


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.
This overrules the 'ignorecase' and 'smartcase' options, when "\c" or "\C" is
used their value doesn't matter.

pattern matches ~
\Cword word
\CWord Word
\cword word, Word, WORD, WoRd, etc.
\cWord word, Word, WORD, WoRd, etc.

A big advantage of using "\c" and "\C" is that it sticks with the pattern.
Thus if you repeat a pattern from the search history, the same will happen, no
matter if 'ignorecase' or 'smartcase' was changed.


Thursday, August 25, 2011

download files from web via the OS x command line

curl -O

You might want to include a few extra bits in that post. First, always include the -L (or –location) switch, since that will allow curl to follow any redirects (if the file gets moved, but there is a redirect for it). Also, if the URL’s file part (the section after the last slash) is not pretty, you can give a name for the downloaded file by using a lower-case -o (instead of -O), followed by a space and the name in quotes. Also, always put the URL in single-quotes – ampersands and a few other characters will break on the command line if they aren’t in quotes. Here’s an example of those ideas combined:

curl -L -o ‘myfile.dmg’ ‘‘


Thursday, August 11, 2011

Download Youtube Video

Download Youtube Video
# cd /usr/ports/www/youtube_dl
# make install clean

step 2)
$ youtube-dl -b -o Linux_WM_show.flv ""

-b best rate
-o output file name

Wednesday, August 10, 2011

找出目錄下所有壞掉的 symblic link

找出目錄下所有壞掉的 symblic link

find . -type l | perl -lne 'print if ! -e'

配合xargs 做刪除動作

find . -type l | perl -lne 'print if ! -e' | xargs rm -rf

Wednesday, August 3, 2011

FreeBSD add a user to group

FreeBSD add a user to group
by Vivek Gite

Q. How do I add a user to group under FreeBSD operating system?

A. You need to use pw command. The pw utility is a command-line based editor for the system user and group files, allowing the superuser an easy to use and standardized way of adding, modifying and removing users and groups. First login as the root using su or sudo command.

Task: Add existing user to group
You would like to add existing user tom to secondary group called ftpusers. Type the command as follows:

# pw groupmod ftpusers -m TEST_NAME

Note: this way user TEST_NAME will be added to group operator without replacing or overwriting anything.

If you want to add the user TEST_NAME to ftpusers group only, and remove the user from other groups:
# pw usermod TEST_NAME -G ftpusers

or specifing multple groups, add TEST_NAME to secondary group ftpusers and wwwusers:
# pw usermod tom -G ftpusers,wwwusers

-G option Set the default groups in which new users are granted membership. This is a separate set of groups from the primary group, and you should avoid nominating the same group as both primary and extra groups.

Task: Add a new user to group
Add new user jerry to system and to secondary group sales:
# pw useradd jerry -G sales
# passwd jerry

First command adds user jerry to secondary group called sales. Second commands set a password for jerry.