<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UKoom &#187; Linux</title>
	<atom:link href="http://www.ukoom.com/tag/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ukoom.com</link>
	<description>Documentum, SharePoint, Alfresco, ECM...</description>
	<lastBuildDate>Tue, 25 Oct 2011 15:11:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Nginx configuration &#8211; nginx.conf</title>
		<link>http://www.ukoom.com/nginx-configuration-nginx-conf.htm</link>
		<comments>http://www.ukoom.com/nginx-configuration-nginx-conf.htm#comments</comments>
		<pubDate>Tue, 10 Aug 2010 11:52:05 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1109</guid>
		<description><![CDATA[server { listen 80; server_name nginx.org www.nginx.org; root /data/www; location / { index index.html index.php; } location ~* \.(gif&#124;jpg&#124;png)$ { expires 30d; } location ~ \.php$ { fastcgi_pass localhost:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } nginx first searches for the most specific location given by literal strings regardless of the listed order. In the [...]]]></description>
			<content:encoded><![CDATA[<blockquote>
<pre>server {
    listen        80;
    server_name   nginx.org  www.nginx.org;
    root          /data/www;

    location / {
        index     index.html  index.php;
    }

    location ~* \.(gif|jpg|png)$ {
        expires   30d;
    }

    location ~ \.php$ {
        fastcgi_pass   localhost:9000;
        fastcgi_param  SCRIPT_FILENAME
                       $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}</pre>
</blockquote>
<p>nginx first searches for the most specific location given by literal strings regardless of the listed order. In the configuration above the only literal location is “<code>/</code>” and since it matches any request it will be used as a last resort. Then nginx checks locations given by regular expression in the order listed in the configuration file. The first matching expression stops the search and nginx will use this location. If no regular expression matches a request, then nginx uses the most specific literal location found earlier.</p>
<p><strong>File excerpt:</strong> <em>nginx.conf location directives</em></p>
<pre>location / { }
location /images/ { }
location /blog/ { }
location /planet/ { }
location /planet/blog/ { }

location ~ IndexPage\.php$ { }
location ~ ^/BlogPlanet(/|/index\.php)$ { }

location ~* \.(pl|cgi|perl|prl)$ { }
location ~* \.(md|mdwn|txt|mkdn)$ { }

location ^~ /images/IndexPage/ { }
location ^~ /blog/BlogPlanet/ { }

location = / { }</pre>
<p>The first five examples are &#8220;literal string&#8221; matches, and match the beginning part of the request following the host portion. In a hypothetical request for <tt><span>http://ducklington.org/</span></tt>, assuming that there is a <tt>server_name</tt> for <tt>ducklington.org</tt>, the &#8220;<tt>location /</tt>&#8221; directive will catch this request. Nginx will always fulfill a request with most specific match. A request for <tt><span>http://ducklington.org/planet/blog/</span></tt> and <tt><span>http://ducklington.org/planet/blog/about/</span></tt> will be fulfilled by the &#8220;<tt>location /planet/blog/</tt>&#8221; even though &#8220;<tt>location /planet/</tt>&#8221; also fills this request.</p>
<p>When a <tt>location</tt> directive is followed by a tilde (e.g. <tt>~</tt>) as in the fourth group of examples, nginx performs a regular expression match. These matches are always case sensitive, so in the first example requests ending in <tt>IndexPage.php</tt> would match, but <tt>indexpage.php</tt> would not. In the second the regular expression <tt><span>^/BlogPlanet(/|index\.php)$</span></tt> will match requests for <tt>/BlogPlanet/</tt> and <tt>/BlogPlanet/index.php</tt>, but <strong>not</strong> <tt>/BlogPlanet</tt>, <tt>/blogplanet/</tt>, or <tt>/blogplanet/index.php</tt>. Nginx uses Perl Compatible Regular Expressions (PCRE).</p>
<p>Using a tilde-asterisk (e.g. <tt>~*</tt>) as an argument to a <tt>location</tt> directive, as in the third group of examples, removes case sensitivity from the matches. These examples all specify how nginx should process requests that end in a particular file extension. In the first example, any file ending in: <tt>.pl</tt>, <tt>.PL</tt>, <tt>.cgi</tt>, <tt>.CGI</tt>, <tt>.perl</tt>, <tt>.Perl</tt>, <tt>.prl</tt>, and <tt>.PrL</tt> (among others) will match the request.</p>
<p>In the next group of examples, the caret-tilde argument (e.g. <tt>^~</tt>) to <tt>location</tt> functions like the literal string matches of the first group. However, when used, they force nginx to stop searching for more specific matches. So in these examples, the <tt>location</tt> directives for &#8220;<tt>^~ /images/IndexPage/</tt>&#8221; and &#8220;<tt>^~ /blog/BlogPlanet/</tt>&#8221; would be used even though the request matches another location directive. See below for more information about the order and priority of <tt>location</tt> directive processing.</p>
<p>Finally, using the equal sign (e.g. <tt>=</tt>) as an argument to <tt>location</tt> forces an exact match with the path requested and then stops searching for more specific matches. For instance, the final example will only match <tt><span>http://ducklington.org/</span></tt> but not <tt><span>http://ducklington.org/index.html</span></tt>. Using exact matches can speed up request times slightly especially when some requests are particularly popular.</p>
<p>Directives are processed in the following manner:</p>
<ul>
<li>Exact string matches are processed first. If a match is found, nginx stops searching and fulfills the request.</li>
<li>Remaining literal string directives are processed next. If the &#8220;<tt>^~</tt>&#8221; argument is used, then ngnix stops here and fulfills the request. Otherwise, nginx continues to process location directives.</li>
<li>All location directives specified by regular expressions (with the <tt>~</tt> and <tt>~*</tt> arguments) are processed. If a regular expression matches the request, nginx stops here and fulfills the request.</li>
<li>When there are no regular expressions, or no regular expressions match, the most specific literal string match is used.</li>
</ul>
<p>It is incumbent upon the administrator to ensure that possible <tt>location</tt> directives will match for every resource nginx is to provide for a given domain within the <tt>server</tt> block. Additionally, while nginx&#8217;s configuration parser is capable of reading nested location blocks, using <tt>location</tt> directives in this manner is not a supported behavior.</p>
<div id="location-configuration"><a name="location_configuration"></a></p>
<h2>Location Configuration <a href="http://library.linode.com/guniDB"><img style="border: medium none; margin: 0px; padding: 0px;" src="http://library.linode.com/images/link-icon.png" alt="Link" /></a></h2>
<p>Once nginx has selected a <tt>location</tt> to provide the resource for a given request, the response to this request is determined by the contents of the location directive block. Allow us to consider the following basic configuration block:</p>
<p><strong>File excerpt:</strong> <em>nginx.conf location directive</em></p>
<pre>location / {
    root   html;
    index  index.html index.htm;
}</pre>
<p>In this example the document root is located in the <tt>html/</tt> directory. Given the default installation prefix for nginx, the full path to this location is <tt>/opt/nginx/http/</tt>. A request for the resource located at <tt>/blog/includes/style.css</tt> and assuming no other location directives matched, would serve the resource located on the file system at <tt>/opt/nginx/html/blog/includes/style.css</tt>. If you like, you can specify absolute paths for the <tt>root</tt> directive.</p>
<p>The <tt>index</tt> directive tells nginx which resource on the file system should be used if the request does not include a file name. Therefore, in this case the request for <tt><span>http://.ducklington.org/</span></tt> would be fulfilled by the resource located at <tt>/opt/nginx/http/index.html</tt>. If multiple files are specified for the <tt>index</tt> directive, nginx will process the list in order and fulfill the request with the first file that exists. If <tt>index.html</tt> doesn&#8217;t exist in the relevant directory, <tt>index.htm</tt> would be used. If neither exist, a 404 message would be sent.</p>
<p>Allow us to consider additional examples of <tt>location</tt> directives from the <a href="http://library.linode.com/web-servers/nginx/perl-fastcgi/debian-5-lenny">serving websites with nginx and Perl-FastCGI guide</a> for a server responding for the domain <tt>ducklington.org</tt>:</p>
<p><strong>File excerpt:</strong> <em>nginx.conf location directive</em></p>
<pre>location / {
    root   /srv/www/ducklington.org/public_html;
    index  index.html index.htm;
}

location ~ \.pl$ {
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass  127.0.0.1:8999;
    fastcgi_index index.pl;
    fastcgi_param  SCRIPT_FILENAME  /srv/www/ducklington.org/public_html$fastcgi_script_name;
}</pre>
<p>In this example, all requests for resources that end in a <tt>.pl</tt> extension are handled by the second location block, which specifies a <tt>fastcgi</tt> handler for these requests. Otherwise, nginx uses the first location directive. Resources are located on the file system at <tt>/srv/www/ducklington.org/public_html/</tt>. If no file name is specified in the request, nginx will look for and provide the <tt>index.html</tt> and <tt>index.htm</tt> files in turn. If no <tt>index</tt> files are found, the server will return a 404 error. Consider the following requests:</p>
<ul>
<li>The request for <tt><span>http://ducklington.org/</span></tt> will return the file located at <tt>/srv/www/ducklington.org/public_html/index.html</tt> if it exists. If that file doesn&#8217;t exist, it will fulfill <tt>/srv/www/ducklington.org/public_html/index.htm</tt>. If neither exists, nginx returns a 404 error.</li>
<li>The request for <tt><span>http://ducklington.org/blog/</span></tt> will return the file located at <tt>/srv/www/ducklington.org/public_html/blog/index.html</tt> if it exists. If that file doesn&#8217;t exist, it will fulfill <tt>/srv/www/ducklington.org/public_html/blog/index.htm</tt>. If neither exists, nginx returns a 404 error.</li>
<li>The request for <tt><span>http://ducklington.org/tasks.pl</span></tt> will use the FastCGI handler to execute the file located at <tt>/srv/www/ducklington.org/public_html/tasks.pl</tt> and return the result.</li>
<li>The request for <tt><span>http://ducklington.org/squire/roster.pl</span></tt> will use the FastCGI handler execute the file located at <tt>/srv/www/ducklington.org/public_html/squire/roster.pl</tt> and return the result.</li>
</ul>
</div>
<p>Reference:</p>
<p><a href="http://www.ukoom.com/wp-content/uploads/2010/08/nginx.conf.zip">nginx.conf.zip</a></p>
<p>http://nginx.org/en/docs/http/request_processing.html</p>
<p>http://library.linode.com/web-servers/nginx/configuration/basic#location_configuration</p>
<p>http://articles.slicehost.com/2009/3/5/ubuntu-intrepid-nginx-configuration</p>
<p>http://blog.rackcorp.com/?p=31</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/nginx-configuration-nginx-conf.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Platform Status: libjvm.so: cannot open shared object file: No such file or directory</title>
		<link>http://www.ukoom.com/platform-status-libjvm-so-cannot-open-shared-object-file-no-such-file-or-directory.htm</link>
		<comments>http://www.ukoom.com/platform-status-libjvm-so-cannot-open-shared-object-file-no-such-file-or-directory.htm#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:46:43 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Documentum]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1034</guid>
		<description><![CDATA[Error &#8221; Generic Status: Library Open failed, Library Name: /dctm65/shared/java/1.5.0_12/jre/lib/i386/libjava.so, Platform Status: libjvm.so: cannot open shared object file: No such file or directory IDQL failed to run.  dmAPIInit() returned a failed status. &#8221; was thrown when executing IDQL command. I came across this issue after I installed one docbase on linux server. It seemed that [...]]]></description>
			<content:encoded><![CDATA[<p>Error &#8221;</p>
<p>Generic Status: Library Open failed, Library Name: /dctm65/shared/java/1.5.0_12/jre/lib/i386/libjava.so, Platform Status: libjvm.so: cannot open shared object file: No such file or directory</p>
<p>IDQL failed to run.  dmAPIInit() returned a failed status.</p>
<p>&#8221; was thrown when executing IDQL command.</p>
<p>I came across this issue after I installed one docbase on linux server.</p>
<p>It seemed that IDQL read the .so file in the wrong place.</p>
<p>I used the link command to resolve this problem:</p>
<p>ln -s /dctm65/shared/java/1.5.0_12/jre/lib/i386/server/libjvm.so /dctm65/shared/java/1.5.0_12/jre/lib/i386/libjvm.so</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/platform-status-libjvm-so-cannot-open-shared-object-file-no-such-file-or-directory.htm/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>chown &#8211; change the owner of a file</title>
		<link>http://www.ukoom.com/chown-change-the-owner-of-a-file.htm</link>
		<comments>http://www.ukoom.com/chown-change-the-owner-of-a-file.htm#comments</comments>
		<pubDate>Thu, 28 Jan 2010 05:34:21 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1031</guid>
		<description><![CDATA[You can change the owner and group of a file or a directory with the chown command. Please, keep in mind you can do this only if you are the root user or the owner of the file. Set the file&#8217;s owner: $ chown username somefile After giving this command, the new owner of a [...]]]></description>
			<content:encoded><![CDATA[<p>You can change the owner  and group of a file or a directory with the <code>chown</code> command.  Please, keep in mind you can do this only if you are the root user or  the owner of the file.</p>
<p>Set the file&#8217;s owner:<br />
<span><code>$ <strong>chown username somefile</strong></code></span><br />
After giving this command, the new owner of a file called <code>somefile</code> will be the user <code>username</code>. The file&#8217;s group owner will not  change. Instead of a user name, you can also give the user&#8217;s numeric ID  here if you want.</p>
<p>You can also set the file&#8217;s group at the same time. If the user  name is followed by a colon and a group name, the file&#8217;s group will be  changed as well.<br />
<span><code>$ <strong>chown username:usergroup  somefile</strong></code></span><br />
After giving this command, <code>somefile</code>&#8216;s new owner would be  user <code>username</code> and the group <code>usergroup</code>.</p>
<p>You can set the owner of a directory exactly the same way you set  the owner of a file:<br />
<span><code>$ <strong>chown username somedir</strong></code></span><br />
Note that after giving this command, only the owner of the <em>directory</em> will change. The owner of the files <em>inside</em> of the directory  won&#8217;t change.</p>
<p>In order to set the ownership of a directory and all the files in  that directory, you&#8217;ll need the <code>-R</code> option:<br />
<span><code>$ <strong>chown -R username somedir</strong></code></span><br />
Here, R stands for <em>recursive</em> because this command will  recursively change the ownership of directories and their contents.  After issuing this example command, the user <code>username</code> will  be the owner of the directory <code>somedir</code>, as well as every  file in that directory.</p>
<p>Tell what happens:</p>
<p><code>$ <strong>chown -v username somefile</strong><br />
changed ownership of 'somefile' to username</code></p>
<p>Here, v stands for <em>verbose</em>. If you use the <code>-v</code> option, <code>chown</code> will list what it did (or didn&#8217;t do) to the  file.</p>
<p>The verbose mode is especially useful if you change the ownership  of several files at once. For example, this could happen when you do it  recursively:</p>
<p><code>$ <strong>chown -Rv username somedir</strong><br />
changed ownership of 'somedir/' to username<br />
changed ownership of 'somedir/boringfile' to username<br />
changed ownership of 'somedir/somefile' to username</code></p>
<p>As you can see, <code>chown</code> nicely reports to you what it  did to each file.</p>
<div>
<div>
<h2>&lt; <strong><span id="chgrp">chgrp  &#8211; change the group ownership of a file</span></strong> &gt;</h2>
<p>In addition to <code>chown</code>, you can also use the <code>chgrp</code> command to change the group of a file or a directory. You must, again,  be either the root user or the owner of the file in order to change the  group ownership.</p>
<p><code>chgrp</code> works pretty much the same way as <code>chown</code> does, except it changes the file&#8217;s user group instead of the owner, of  course.<br />
<span><code>$ <strong>chgrp usergroup somefile</strong></code></span><br />
After issuing this command, the file <code>somefile</code> will be  owned by a user group <code>usergroup</code>. Although the file&#8217;s group  has changed to <code>usergroup</code>, the file&#8217;s owner will still be  the same.</p>
<p>The options of using <code>chgrp</code> are the same as using <code>chown</code>.  So, for example, the <code>-R</code> and <code>-v</code> options will  work with it just like they worked with <code>chown</code>:</p>
<p><code>$ <strong>chgrp -Rv usergroup somedir</strong><br />
changed group of 'somedir/' to usergroup<br />
changed group of 'somedir/boringfile' to usergroup<br />
changed group of 'somedir/somefile' to usergroup</code></p>
<p><code>chown</code> nicely reports to you what it did to each file.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/chown-change-the-owner-of-a-file.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An internal virtual machine error (13) has occurred</title>
		<link>http://www.ukoom.com/an-internal-virtual-machine-error-13-has-occurred.htm</link>
		<comments>http://www.ukoom.com/an-internal-virtual-machine-error-13-has-occurred.htm#comments</comments>
		<pubDate>Thu, 28 Jan 2010 04:13:29 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1028</guid>
		<description><![CDATA[when I booted the Red Hat WS 4 image, I received the following error: &#8220;An internal virtual machine error (13) has occurred.  The virtual machine will reset now.&#8221; To resolve this error, first boot in single user mode: In GRUB menu select Red Hat Linux with the version of the kernel that you wish to [...]]]></description>
			<content:encoded><![CDATA[<p>when I booted the Red Hat WS 4 image, I received the following error:  &#8220;An internal virtual machine error (13) has occurred.  The virtual  machine will reset now.&#8221;</p>
<p>To resolve this error, first boot in single user mode:</p>
<ol>
<li>In  GRUB menu select Red Hat Linux with the version of the kernel that you  wish to boot and type <strong>e</strong> for edit. You will be presented  with a list of items in the configuration file for the title you just  selected.</li>
<li>Select the line that starts with kernel and type <strong>e</strong> to edit the line.</li>
<li>Go to the end of the line and type <strong>single</strong> as a separate word. Press enter to exit edit mode.</li>
<li>Back at  the GRUB screen, type <strong>b </strong>to boot into single user mode.</li>
</ol>
<p>Next, edit /etc/X11/xorg.conf and replace set the  Driver to &#8220;vesa&#8221;.  Also, set the DefaultDepth to 16 from 24.  The  implementation of the S3 hardware doesn&#8217;t support a colordepth of 24 and  will cause the error 13.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/an-internal-virtual-machine-error-13-has-occurred.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Find Files Containing Text</title>
		<link>http://www.ukoom.com/linux-find-files-containing-text.htm</link>
		<comments>http://www.ukoom.com/linux-find-files-containing-text.htm#comments</comments>
		<pubDate>Wed, 27 Jan 2010 05:54:48 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1023</guid>
		<description><![CDATA[Find files that contain a text string: grep -lir &#8220;some text&#8221; * The -l switch outputs only the names of files in which the text occurs (instead of each line containing the text), the -i switch ignores the case, and the -r descends into subdirectories.]]></description>
			<content:encoded><![CDATA[<p>Find files that contain a text string:</p>
<p>grep -lir &#8220;some text&#8221; *</p>
<p>The -l switch outputs only the names of files in which the text occurs (instead of each line containing the text), the -i switch ignores the case, and the -r descends into subdirectories.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/linux-find-files-containing-text.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IF Else in bash of linux</title>
		<link>http://www.ukoom.com/if-else-in-bash-of-linux.htm</link>
		<comments>http://www.ukoom.com/if-else-in-bash-of-linux.htm#comments</comments>
		<pubDate>Fri, 18 Dec 2009 05:31:16 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=973</guid>
		<description><![CDATA[If/Else In order for a script to be very useful, you will need to be able to test the conditions of variables. Most programming and scripting languages have some sort of if/else expression and so does the bourne shell. Unlike most other languages, spaces are very important when using an if statement. Let&#8217;s do a [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: small;"><strong>If/Else</strong></span></p>
<p>In order for a script to be very useful, you will need to be able to test the conditions of variables. Most programming and scripting languages have some sort of if/else expression and so does the bourne shell. Unlike most other languages, spaces are very important when using an <strong>if</strong> statement.  Let&#8217;s do a simple script that will ask a user for a password before allowing him to continue.  This is obviously 	not how you would implement such security in a real system, but it will make a good example of using <strong>if</strong> and <strong>else</strong> statements.</p>
<pre>#!/bin/sh
# This is some secure program that uses security.

VALID_PASSWORD="secret" #this is our password.

echo "Please enter the password:"
read PASSWORD

if [ "$PASSWORD" == "$VALID_PASSWORD" ]; then
	echo "You have access!"
else
	echo "ACCESS DENIED!"
fi</pre>
<p>Remember that the spacing is very important in the if statement.  Notice that the termination of the if statement is <strong>fi</strong>.  You will need to use 	the <strong>fi</strong> statement to terminate an if whether or not use use an else as well. You can also replace the &#8220;==&#8221; with &#8220;!=&#8221; to test if the variables are NOT equal. There are other tokens that you can put in place of the &#8220;==&#8221; for other types of tests. The following table shows the different expressions allowed.</p>
<p><strong>Comparisons:</strong></p>
<table border="1">
<tbody>
<tr>
<td><strong>-eq</strong></td>
<td>equal to</td>
</tr>
<tr>
<td><strong>-ne</strong></td>
<td>not equal to</td>
</tr>
<tr>
<td><strong>-lt</strong></td>
<td>less than</td>
</tr>
<tr>
<td><strong>-le</strong></td>
<td>less than or equal to</td>
</tr>
<tr>
<td><strong>-gt</strong></td>
<td>greater than</td>
</tr>
<tr>
<td><strong>-ge</strong></td>
<td>greater than or equal to</td>
</tr>
</tbody>
</table>
<p><strong>File Operations:</strong></p>
<table border="1">
<tbody>
<tr>
<td><strong>-s</strong></td>
<td>file exists and is not empty</td>
</tr>
<tr>
<td><strong>-f</strong></td>
<td>file exists and is not a directory</td>
</tr>
<tr>
<td><strong>-d</strong></td>
<td>directory exists</td>
</tr>
<tr>
<td><strong>-x</strong></td>
<td>file is executable</td>
</tr>
<tr>
<td><strong>-w</strong></td>
<td>file is writable</td>
</tr>
<tr>
<td><strong>-r</strong></td>
<td>file is readable</td>
</tr>
</tbody>
</table>
<p>Let&#8217;s try using a couple of these in a script. This next script will ask for a user name, if there is not a file that exists with the name &#8220;username_DAT&#8221;, the script will prompt the user for their age, it will then make sure that they are old enough to use this program and then it will write their age to a file with the name &#8220;username_DAT&#8221;. If the file already exists, it will just display the age of the user.</p>
<pre>#!/bin/sh

# Prompt for a user name...
echo "Please enter your name:"
read USERNAME

# Check for the file.
if [ -s ${USERNAME}_DAT ]; then
        # Read the age from the file.
        AGE=`cat ${USERNAME}_DAT`
        echo "You are $AGE years old!"
else
        # Ask the user for his/her age
        echo "How old are you?"
        read AGE

	if [ "$AGE" -le 2 ]; then
		echo "You are too young!"
	else
		if [ "$AGE" -ge 100 ]; then
			echo "You are too old!"
		else
        		# Write the age to a new file.
        		echo $AGE &gt; ${USERNAME}_DAT
        	fi
        fi
fi</pre>
<p>Run this program a couple of times. First run it and give it the user name of &#8220;john&#8221;. When it asks for an age, enter the age &#8220;1&#8243;. Notice that it will say that you are too you and then exit. Now run the program again with the name &#8220;john&#8221; and the age 200. This time the script will tell you that you are too old and exit. Now run the the script again with the name of &#8220;john&#8221;, enter the age 30. The script exits normally this time, the program created a file called &#8220;john_DAT&#8221; which contains the text &#8220;30&#8243;. Finally run the program one more time and give it the name &#8220;john&#8221;. This time it will not prompt you to enter an age, instead it will read the age from a file and say &#8220;Your are 30 years old!&#8221;.</p>
<p>We introduced something else new in this script.  On line 10 of the file, we see the code:</p>
<pre>	AGE=`cat ${USERNAME}_DAT`</pre>
<p>This is how you execute a command and put the text output from the command into a variable.  The unix command <strong>cat</strong> reads the file 	named <strong>${USERNAME}_DAT</strong> and outputs it to the console.  Instead of putting it to the console in our script, we wrap the command with 	the character <strong>`</strong>, this puts the text into our variable AGE.</p>
<p>You can test multiple expressions at once by using the <strong>||</strong> (or) operator or the <strong>&amp;&amp;</strong> (and) operator. This can save you from writing extra code to nest if statements. The above code has a nested if statement where it checks if the age is greater than or equal to 100. This could be changed as well by using <strong>elif</strong> (else if).  The structure of <strong>elif</strong> is the same as the structure of <strong>if</strong>, we will use it in an example below. In this example, we will check for certain age ranges. If you are less than 20 or greater than 50, you are out of the age range. If you are between 20 and 30 you are in your 20&#8242;s and so on.</p>
<pre>#!/bin/sh

# Prompt for a user name...
echo "Please enter your age:"
read AGE

if [ "$AGE" -lt 20 ] || [ "$AGE" -ge 50 ]; then
	echo "Sorry, you are out of the age range."
elif [ "$AGE" -ge 20 ] &amp;&amp; [ "$AGE" -lt 30 ]; then
	echo "You are in your 20s"
elif [ "$AGE" -ge 30 ] &amp;&amp; [ "$AGE" -lt 40 ]; then
	echo "You are in your 30s"
elif [ "$AGE" -ge 40 ] &amp;&amp; [ "$AGE" -lt 50 ]; then
	echo "You are in your 40s"
fi</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/if-else-in-bash-of-linux.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copy and Paste in VI</title>
		<link>http://www.ukoom.com/copy-and-paste-in-vi.htm</link>
		<comments>http://www.ukoom.com/copy-and-paste-in-vi.htm#comments</comments>
		<pubDate>Fri, 18 Dec 2009 05:27:04 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=971</guid>
		<description><![CDATA[The command ‘Y’ or ‘yy’ copies (yanks) one or more lines. To copy one line, two lines, 10 lines, and all lines to the end of the file, respectively: Y 2Y 10Y yG To paste the text contained in the buffer above (uppercase P) or below the current cursor position (lowercase p), respectively: P p [...]]]></description>
			<content:encoded><![CDATA[<p>The command ‘Y’ or ‘yy’ copies (yanks) one or more lines. To copy one line, two lines, 10 lines, and all lines to the end of the file, respectively:</p>
<p><code>Y<br />
2Y<br />
10Y<br />
yG</code></p>
<p>To paste the text contained in the buffer above (uppercase P) or below the current cursor position (lowercase p), respectively:</p>
<p><code>P<br />
p</code></p>
<p>It is also possible to yank text within a line. The following commands yank text from the current cursor position to the end of the word and the end of the line, respectively:</p>
<p><code>yw<br />
y$</code></p>
<p>The same commands paste the text within a line.  Lower case p pastes after the cursor position and upper case P pastes before.</p>
<p>Paste will also work with deleted text, either lines or parts of lines. Be careful not to execute any other commands prior to pasting as this will empty the buffer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/copy-and-paste-in-vi.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resource:Linux general command.chm</title>
		<link>http://www.ukoom.com/resourcelinux-general-command-chm.htm</link>
		<comments>http://www.ukoom.com/resourcelinux-general-command-chm.htm#comments</comments>
		<pubDate>Thu, 03 Dec 2009 10:41:38 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=933</guid>
		<description><![CDATA[Linux general commandLinux general command]]></description>
			<content:encoded><![CDATA[<p>Linux general command<a href="http://www.ukoom.com/wp-content/uploads/2009/12/Linux-general-command.zip">Linux general command</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/resourcelinux-general-command-chm.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LS命令按时间排序</title>
		<link>http://www.ukoom.com/ls%e5%91%bd%e4%bb%a4%e6%8c%89%e6%97%b6%e9%97%b4%e6%8e%92%e5%ba%8f.htm</link>
		<comments>http://www.ukoom.com/ls%e5%91%bd%e4%bb%a4%e6%8c%89%e6%97%b6%e9%97%b4%e6%8e%92%e5%ba%8f.htm#comments</comments>
		<pubDate>Wed, 02 Dec 2009 06:57:24 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=921</guid>
		<description><![CDATA[ls -l -t为按时间排序显示,默认为新的排在前面,可用下面的命令更改升降序: ls -lrt 最新的文件排在后面(升序) ls -lnt 最新的文件排在前面(降序)]]></description>
			<content:encoded><![CDATA[<p>ls -l -t为按时间排序显示,默认为新的排在前面,可用下面的命令更改升降序:<br />
ls -lrt  最新的文件排在后面(升序)<br />
ls -lnt 最新的文件排在前面(降序)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/ls%e5%91%bd%e4%bb%a4%e6%8c%89%e6%97%b6%e9%97%b4%e6%8e%92%e5%ba%8f.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VI操作手册</title>
		<link>http://www.ukoom.com/vi%e6%93%8d%e4%bd%9c%e6%89%8b%e5%86%8c.htm</link>
		<comments>http://www.ukoom.com/vi%e6%93%8d%e4%bd%9c%e6%89%8b%e5%86%8c.htm#comments</comments>
		<pubDate>Thu, 12 Nov 2009 01:26:05 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=723</guid>
		<description><![CDATA[网上有太多关于VI的操作手册了，以下是我从网络上随机找到的短文，以后会把个人的经验都加入来。 vim有3中主要的模式： 1.normal mode：当进入vim时，默认的模式就是normal mode。在此模式下，无法输入任何文字，不过可以利用按键命令来执行许多操作命令，例如移动光标位置、复制、删除。 2.insert mode：进入vim输入a、i、或o键。即可进入insert mode，此模式下可以输入文字内容。 3.command-line mode：在norma lmode中输入“:”即会进入command-line mode，在此模式下，可以做一些与输入文字无关的事，例如搜索字符串、保存文件或结束编辑等。 在normal mode下： h：将光标向左移动一格 l：将光标向右移动一格 j：将光标向下移动一格 k：将光标向上移动一格 ctrl+b：将页面向前卷动一页 ctrl+f：将页面向后卷动一页 0：将光标移到该行最前面 $：将光标移到该行的最后面 G：将光标移到最后一行的开头 w或W：将光标移到下一个字 若输入“w”，则标点符号如“.”，“,”，“/”等字符都被当成一个字 e或E：将光标移到本单字的最后一个字符；如果光标所在位置为本单子的最后一个字符，则跳到下一个单字的最后一个字符。 若输入“w”，则标点符号如“.”，“,”，“/”等字符都被当成一个字 b：将光标移到本单词的第一个字符；如果光标所在位置为本单词的第一个字符，则跳到上一个单字的第一个字符。 ctrl+u：将光标向前移动半页 ctrl+d：将光标向右移动半页 ctrl+e：屏幕向下卷动一行，也可以说文章和光标向上卷动一行 ctrl+y：屏幕向上卷动一行，也可以说文章和光标向下卷动一行 在command-line mode下： e 文件的路径及名称：打开指定文件 a：从当前光标所在的位置的下一个字符开始输入 i：在光标所在的位置插入新输入的字符 o：新增加的一行，并将光标移到下一行的开头 w：文件的路径及名称 保存文件 q：退出vim Vim的常用操作命令 复制文字 yy：可将光标目前所在位置的正行复制，复制时不会将文字反白显示 nyy：其中n为数字键，表示要复制的行数，若按3yy，则连同光标所在的位置的一行，与下面2行一起复制 yw：可复制光标所在位置到整个单词结束的字符 nyw：n表示要复制的单词数目，若按3yw，则会将目前光标所在位置到单词结束，以及后面的2个字一起复制 p：可将复制的文字粘贴到当前光标所在的位置。若复制的是整行文字，则会将整行内容粘贴在光标所在位置的下一行 删除文字 d：先按d键，放开后按←键，可将光标位置前一个字符删除；按→键，则会将光标位置的字符删除；按↑键，可将当前光标所在的行与前一行一并删除。按↓键，可将当前的光标所在的行与下一行删除。 D：可删除一行中光标所在位置之后的所有字符。 dd：连续按2次d键可删除光标所在的那一行。 dw：将光标停在某个字的第一个字符，按dw键时，会将此字整个删除。如将光标置在某个字中间的字符上，则会将此字中光标后面的字符删除。 nd：n为数字，如按3d，再按下↑键，则删除光标上方的3行，再包括本身1行，共删除4行。若按下↓键，则删除光标下方3行再包括本身1行，共4行。 ndd：若按3dd键，表示删除当前光标位置的1行和下面的2行。 x：删除光标所在位置的字符 X：删除光标所在位置的前一个字符，与d+←键一样 nx：按4x键，表示删除光标位置后的3个字符和光标本身所在的字符 nX：按4X键，表示删除光标位置之前的4个字符（不包括光标的字符） 查找及替换文字 /或？：当药搜索文章中的某一个字符串时，可输入“/”或“?”，然后在输入要查找的字符串。例如输入“/kuka”，然后按回车键，vim就会把所有的gz字符串标记起来，并自动将光标移到第一个找到的字符串上。 n：将光标移到下一个找到的字符串上 N：将光标移到上一个找到的字符串上 r：替换光标所在的位置的字符。修改内容不一定要进入insert mode，在normal mode中，只要将光标移到要更改的字符上，然后按R键，就可以输入要查找的字符了。 [...]]]></description>
			<content:encoded><![CDATA[<p class="0">网上有太多关于VI的操作手册了，以下是我从网络上随机找到的短文，以后会把个人的经验都加入来。</p>
<p class="0">
<p class="0"><span style="font-size: 10.5pt; font-family: '宋体';"><span>vim有3中主要的模式：</span></span></p>
<p class="0"><span style="font-size: 10.5pt; font-family: '宋体';"> 1.</span><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">normal mode</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：当进入vim时，默认的模式就是normal mode。在此模式下，无法输入任何文字，不过可以利用按键命令来执行许多操作命令，例如移动光标位置、复制、删除。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; font-family: '宋体';"> 2.</span><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">insert mode</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：进入vim输入a、i、或o键。即可进入insert mode，此模式下可以输入文字内容。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; font-family: '宋体';"> 3.</span><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">command-line mode</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：在norma lmode中输入“:”即会进入command-line mode，在此模式下，可以做一些与输入文字无关的事，例如搜索字符串、保存文件或结束编辑等。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; font-family: '宋体';"><span>在</span></span><span style="font-weight: bold; font-size: 10.5pt; font-family: '宋体';">normal mode</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>下：</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">h</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标向左移动一格</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">l</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标向右移动一格</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">j</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标向下移动一格</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">k</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标向上移动一格</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">ctrl+b</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将页面向前卷动一页</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">ctrl+f</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将页面向后卷动一页</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">0</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标移到该行最前面</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">$</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标移到该行的最后面</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">G</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标移到最后一行的开头</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">w</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>或</span></span><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">W</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标移到下一个字</span></span></p>
<table style="border-collapse: collapse;" border="0">
<tbody>
<tr>
<td style="border: 0.5pt solid #000000; padding: 0pt 5.4pt; width: 426.1pt;" width="568" valign="top">
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; font-family: '宋体';"><span>若输入“w”，则标点符号如“.”，“,”，“/”等字符都被当成一个字</span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">e</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>或</span></span><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">E</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标移到本单字的最后一个字符；如果光标所在位置为本单子的最后一个字符，则跳到下一个单字的最后一个字符。</span></span></p>
<table style="border-collapse: collapse;" border="0">
<tbody>
<tr>
<td style="border: 0.5pt solid #000000; padding: 0pt 5.4pt; width: 426.1pt;" width="568" valign="top">
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; font-family: '宋体';"><span>若输入“w”，则标点符号如“.”，“,”，“/”等字符都被当成一个字</span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">b</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标移到本单词的第一个字符；如果光标所在位置为本单词的第一个字符，则跳到上一个单字的第一个字符。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">ctrl+u</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标向前移动半页</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">ctrl+d</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标向右移动半页</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">ctrl+e</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：屏幕向下卷动一行，也可以说文章和光标向上卷动一行</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">ctrl+y</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：屏幕向上卷动一行，也可以说文章和光标向下卷动一行</span></span></p>
<p class="0" style="text-align: justify;">
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; font-family: '宋体';"><span>在</span></span><span style="font-weight: bold; font-size: 10.5pt; font-family: '宋体';">command-line mode</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>下：</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">e</span><span style="font-size: 10.5pt; font-family: '宋体';"> <span>文件的路径及名称：打开指定文件</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">a</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：从当前光标所在的位置的下一个字符开始输入</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">i</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：在光标所在的位置插入新输入的字符</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">o</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：新增加的一行，并将光标移到下一行的开头</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">w</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：文件的路径及名称 保存文件</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">q</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：退出vim</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-weight: bold; font-size: 14pt; font-family: '宋体';">Vim<span>的常用操作命令</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体';"><span>复制文字</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">yy</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：可将光标目前所在位置的正行复制，复制时不会将文字反白显示</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">nyy</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：其中n为数字键，表示要复制的行数，若按3yy，则连同光标所在的位置的一行，与下面2行一起复制</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">yw</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：可复制光标所在位置到整个单词结束的字符</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">nyw</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：n表示要复制的单词数目，若按3yw，则会将目前光标所在位置到单词结束，以及后面的2个字一起复制</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">p</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：可将复制的文字粘贴到当前光标所在的位置。若复制的是整行文字，则会将整行内容粘贴在光标所在位置的下一行</span></span></p>
<p class="0" style="text-align: justify;">
<p class="0" style="text-align: justify;"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体';"><span>删除文字</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">d</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：先按d键，放开后按←键，可将光标位置前一个字符删除；按→键，则会将光标位置的字符删除；按↑键，可将当前光标所在的行与前一行一并删除。按↓键，可将当前的光标所在的行与下一行删除。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">D</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：可删除一行中光标所在位置之后的所有字符。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">dd</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：连续按2次d键可删除光标所在的那一行。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">dw</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标停在某个字的第一个字符，按dw键时，会将此字整个删除。如将光标置在某个字中间的字符上，则会将此字中光标后面的字符删除。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">nd</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：n为数字，如按3d，再按下↑键，则删除光标上方的3行，再包括本身1行，共删除4行。若按下↓键，则删除光标下方3行再包括本身1行，共4行。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">ndd</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：若按3dd键，表示删除当前光标位置的1行和下面的2行。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">x</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：删除光标所在位置的字符</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">X</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：删除光标所在位置的前一个字符，与d+←键一样</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">nx</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：按4x键，表示删除光标位置后的3个字符和光标本身所在的字符</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">nX</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：按4X键，表示删除光标位置之前的4个字符（不包括光标的字符）</span></span></p>
<p class="0" style="text-align: justify;">
<p class="0" style="text-align: justify;"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体';"><span>查找及替换文字</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">/<span>或？</span></span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：当药搜索文章中的某一个字符串时，可输入“/”或“?”，然后在输入要查找的字符串。例如输入“/kuka”，然后按回车键，vim就会把所有的gz字符串标记起来，并自动将光标移到第一个找到的字符串上。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">n</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标移到下一个找到的字符串上</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">N</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：将光标移到上一个找到的字符串上</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">r</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：替换光标所在的位置的字符。修改内容不一定要进入insert mode，在normal mode中，只要将光标移到要更改的字符上，然后按R键，就可以输入要查找的字符了。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">R</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：连续替换光标所在的位置的字符，按Esc键停止替换</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">cc</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：按cc键可以替换光标所在的那一行</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';"><span>替换字符串</span></span><span style="font-size: 10.5pt; font-family: '宋体';"><span>： 当要将文章中的某一个字符串全部替换时（例如将所有的temp替换成tmp），使用“:g/temp/s//tmp/g”或“:1,$stemp/tmp /g”命令，可立刻将所有的“temp”替换成“tmp”字符串。如果不是所有的“temp”字符串都要替换时，可用“:g/temp/s//tmp /gc”或“:1/,$stemp/tmp/gc”命令。则找到每一个“temp”字符串时，都会将整行显示在屏幕的下方，可输入“y”或“n”决定是否 要替换。</span></span></p>
<p class="0" style="text-align: justify;">
<p class="0" style="text-align: justify;"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体';"><span>显示光标所在的行数、移到指定的行数</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">^g<span>、^G</span></span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：按次组合键，则会在最下方处显示光标所造位置的行数，以及文章的总行数。</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">nG</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：n为数字，若按下20G，则可将光标移到第20行。</span></span></p>
<p class="0" style="text-align: justify;">
<p class="0" style="text-align: justify;"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体';"><span>还原</span></span></p>
<p class="0" style="text-align: justify;"><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">u</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：按此键就是在执行undo命令，可取消前一次的操作</span></span></p>
<p><span style="font-size: 10.5pt; color: #0000ff; font-family: '宋体';">^r</span><span style="font-size: 10.5pt; font-family: '宋体';"><span>：按此键就是执行redo命令，可以恢复刚才undo的操作</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/vi%e6%93%8d%e4%bd%9c%e6%89%8b%e5%86%8c.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

