<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
  <channel>
    <title>Learning @ StarAhead.com</title>
    <link>http://starahead.com/learning/</link>
    <description>Knowledge for All</description>
    <language>en-us</language>           
    <generator>Nucleus CMS v3.22</generator>
    <copyright>©</copyright>             
    <category>Weblog</category>
    <docs>http://backend.userland.com/rss</docs>
    <image>
      <url>http://starahead.com/learning//nucleus/nucleus2.gif</url>
      <title>Learning @ StarAhead.com</title>
      <link>http://starahead.com/learning/</link>
    </image>
    <item>
 <title>Create a Simple Reflective Text using Inkscape for Web</title>
 <link>http://starahead.com/learning/index.php?itemid=27</link>
<description><![CDATA[In the quest for finding a good Open Source software for my web works, I came across this wonderful software called "<b>Inkscape</b>" (<a href="http://www.inkscape.org">http://www.inkscape.org</a> - Version 0.46) - Inkscape is <i>an Open Source vector graphics editor, with capabilities similar to Illustrator, CorelDraw, or Xara X, using the W3C standard Scalable Vector Graphics (SVG) file format</i>. Before this I use Adobe Photoshop to create this simple reflective effect. This tutorial is to use Inkscape to create the simple transparent reflective text - to PNG format.
Firstly, run the Inkscape software, and open New file (or just take the default blank document.

Create your desired Text by using the <b>Text</b> tool.

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex01a.png">Select the Text tool</a>
<p>

drag the text box and type your desired text - in this case I just type "Welcome".

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex02.jpg">type anything, eg. Welcome</a>
<p>

once done, select the text object, 

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex03.jpg">select the text object (using left-click)</a>
<p>

then do a <b>Right-click</b>, and then select "<b>Duplicate</b>" (or just use the shortcut Ctrl-D)

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex04.jpg">Select Duplicate from the right-click menu</a>
<p>

This will create a copy of the text object. Then from the "<b>Object</b>" Menu, select the "<b>Flip Vertical</b>" option, to create a "mirror" image of the text object.

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex05.jpg">Select &quot;Flip Vertical&quot; from the &quot;Object&quot; menu</a>
<p>

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex06.jpg">The flip-vertical output</a>
<p>


without pressing any other keys, just use the down arrow key (on your keyboard obviously) to move the duplicate copy of the text object. Move it downward to the position as shown below

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex07.jpg">Move the duplicate copy to this position</a>
<p>

with the duplicate copy still selected, press the <b>Shift-Ctrl-F</b> to bring the "Fill and Stroke" window. 

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex09.jpg">press the Shift-Ctrl-F to get the fill-and-stroke window</a>
<p>

Select the "<b>Fill</b>" tab, then Select the "<b>Linear gradient</b>" option, this will turn the fill option of the duplicate-text into a linear-gradient.

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex10.jpg">Change the fill type to Linear Gradient</a>
<p>

After that choose the "<b>Create and edit Gradient</b>" tools from the tools-bar onthe left

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex11a.png">choose the Create-and-edit-gradient tool</a><p>


from the Linear-Gradient position:

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex12.jpg">Linear-Gradient position</a><p>


adjust the gradient to be like this

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex13.jpg">adject the gradient to this position</a><p>


You will get this when done 

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex14.jpg">after adjust the gradient</a><p>


Now, drag your mouse to select both the Text object

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex15.jpg">select both text objects</a><p>

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex16.jpg">select both Text object</a><p>


Then Select "<b>File</b>" -> "<b>Export Bitmap</b>" option.

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex17.jpg">Select Export Bitmap from File menu</a><p>


You should get the "<b>Export Bitmap</b>" window

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex18.jpg">Export Bitmap Window</a><p>


Fill in the filename location  and make sure you put the "<b>.png</b>" extension to make it in <b>PNG </b>format.

Now you should have a PNG file ready to be used for your Web page.

A simple html code like below will demonstrate the usage of the PNG output

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex20.jpg">sample HTML code</a><p>


This is the sample output on browser:

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex19.jpg">Sample output 1</a><p>


Output with different font:

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex21.jpg">Sample output 2</a><p>


Output with different color:

<p>
<a href="http://starahead.com/learning/media/2/20090224-reflex22.jpg">Sample Output 3</a><p>


Keeps on experimenting with the procedure by adding more effects, Thats all for now. 

Have fun.
]]></description>
 <category>Inkscape</category>
<comments>http://starahead.com/learning/index.php?itemid=27</comments>
 <pubDate>Tue, 24 Feb 2009 22:58:45 -0800</pubDate>
</item><item>
 <title>Workaround for Symantec Endpoint Protection VirusDefs issues</title>
 <link>http://starahead.com/learning/index.php?itemid=26</link>
<description><![CDATA[At the office, we are using the Symantec Endpoint Protection (corporate edition) anti-virus solution. One day we realise that every computers running Windows XP Professional in the office is having an issue with low disk space. After a details check-up we found out that the Symantec is storing all the virus definition updates in the <b>"C:\Program Files\Common Files\Symantec Shared\VirusDefs\"</b> folder and it will never gets deleted ! most computers will have at least 20-40GB alone in that folder. The workaround is by using this simple MSDOS batch file to actually delete all the TMP files in that folder.
The MSDOS batch file (or you can call it script) is as below:
<p>
<pre>
cd "C:\Program Files\Common Files\Symantec Shared\VirusDefs\"
for /F "tokens=*" %%G IN ('dir /b /ad "C:\Program Files\Common Files\Symantec 
Shared\VirusDefs\*.tmp"') do RD /S /Q %%G
exit
</pre>
<p>
bare in mind that the "for" statements is in one line. Just use any text editor to create this MSDOS batch file, and give a usefult name like "symantecfix.bat". save it in one folder under C:\ (for example C:\scripts ).
<p>
Some explanation on the scripts. firstly it will actually Change Directory to the "C:\Program Files\Common Files\Symantec Shared\VirusDefs\", Then it will use the "for" loop to just list out all the *.tmp files in the directory (again here to be safe I include the whole path - just to be sure). 
<P>
Afterthat once we are in the loop with all the *.tmp files, it will execute the "RD /S /Q filename.tmp" command. RD is a "Remove Directory" (including all the files in the sub-directory), the /S to include the sub-directory, and /Q to skip all the Yes/No question. The <b>%%G</b> is the variable to hold the *.tmp filename - if you were to test this "for" loop at the MSDOS command line (not from the scripts) you should use <b>%G</b> instead. Lastly is the "exit" command - this will just close the MSDOS environment, optional only.
<p>
To execute the script, just open the MSDOS window (command "cmd"), change directory to the location of the script file, then type the full filename - in this case symantec.bat, to execute it.
<p>
To make it automated, you can use the "Scheduled Task" (from Control Panel). You can make it daily or weekly depend on your preferences.
<p>
Have fun.

]]></description>
 <category>General</category>
<comments>http://starahead.com/learning/index.php?itemid=26</comments>
 <pubDate>Wed, 28 Jan 2009 21:26:41 -0800</pubDate>
</item><item>
 <title>Using Margin in HTML</title>
 <link>http://starahead.com/learning/index.php?itemid=25</link>
<description><![CDATA[Sometimes when creating a webpage we really need to have a kind of neat looking page but been spoiled by the default margin in HTML Here are some information that I have to control the margin in HTML.
Another issues are that they are many Web Browser available nowadays, and some keyword in HTML might behave differently in different browser. in this example I will just use 2 most frequently used browser, IE and Firefox.
<br><br>
Consider having this code (below):
<br><br>
<pre>
&lt;html&gt;
&lt;<b>body</b>&gt;
&lt;center&gt;
&lt;table width=100% height=100%&gt;
&lt;tr height=30%&gt;&lt;td bgcolor=#c0c0c0&gt;Row1 at 30%&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=70%&gt;&lt;td bgcolor=#909090&gt;Row2 at 70%&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<br><br>
<a href="http://starahead.com/learning/media/2/20070612-margin01.png">figure 1: Firefox output</a><br> 
<a href="http://starahead.com/learning/media/2/20070612-margin01a.png">figure 1a: IE output</a>

<br><br>
Notice the white border at each side of the webpage... That is HTML Margin that I am planning to get rid off here.

lets start by removing the left and top margin first, the new code will be like below:
<br><br>
<pre>
&lt;html&gt;
&lt;body <b>leftmargin=0 topmargin=0</b>&gt;
&lt;center&gt;
&lt;table width=100% height=100%&gt;
&lt;tr height=30%&gt;&lt;td bgcolor=#c0c0c0&gt;Row1 at 30%&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=70%&gt;&lt;td bgcolor=#909090&gt;Row2 at 70%&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<br><br>
this will give the output below:
<br><br>


<a href="http://starahead.com/learning/media/2/20070612-margin02.png">figure 2: Firefox output</a><br> 
<a href="http://starahead.com/learning/media/2/20070612-margin02a.png">figure 2a: IE output</a>

<br><br>
As you can see, in IE browser, "topmargin" and "leftmargin" is quite enough to remove the margin, but FireFox still shows the right and bottom margin.

Lets add more to our code below:
<br><br>
<pre>
&lt;html&gt;
&lt;body <b>leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0</b>&gt;
&lt;center&gt;
&lt;table width=100% height=100%&gt;
&lt;tr height=30%&gt;&lt;td bgcolor=#c0c0c0&gt;Row1 at 30%&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=70%&gt;&lt;td bgcolor=#909090&gt;Row2 at 70%&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<br><br>
Now the Firefox will have a clean zero margin at all side. same goes to the IE browser.
<br><br>

<a href="http://starahead.com/learning/media/2/20070612-margin03.png">figure 3: Firefox output</a><br>
<a href="http://starahead.com/learning/media/2/20070612-margin03a.png">figure 3a: IE output</a>

<br><br>

To have a complete no-margin at all you can just remove the cell margin in the &lt;table&gt; HTML section.<br>
The final code will be like below:
<br><br>
<pre>
&lt;html&gt;
&lt;body <b>leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0</b>&gt;
&lt;center&gt;
&lt;table width=100% height=100% <b>cellpadding=0 cellspacing=0</b>&gt;
&lt;tr height=30%&gt;&lt;td bgcolor=#c0c0c0&gt;Row1 at 30%&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=70%&gt;&lt;td bgcolor=#909090&gt;Row2 at 70%&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<br><br>
The final output on both browser will be like below:
<br><br>
<a href="http://starahead.com/learning/media/2/20070612-margin04.png">Figure 4: Firefox output</a><br>
<a href="http://starahead.com/learning/media/2/20070612-margin04a.png">Figure 4a: IE output</a>
<br><br>

<b><font size=+2>Have fun.</font></b>
<br><br>]]></description>
 <category>Web</category>
<comments>http://starahead.com/learning/index.php?itemid=25</comments>
 <pubDate>Tue, 12 Jun 2007 21:07:33 -0700</pubDate>
</item><item>
 <title>Using Google Calendar</title>
 <link>http://starahead.com/learning/index.php?itemid=24</link>
<description><![CDATA[Google has introduce a very nice tool, the Web Calendar. It's online, you can access it anywhere as long as you have the internet access, and it's quite handy been able to add,view and update it anytime convenience to you. Another good feature are, you can actually share your calendar with your family and friends - of course you can set what others can see and what they can't see.The Google web calendar are available at URL: <a href="http://www.google.com/calendar">http://www.google.com/calendar</a>. The front page is like below.
<p>
<a href="http://starahead.com/learning/media/2/20060509-gcal01.jpg">Google Calendar front page</a>
<p>
Once you have successfully login into it, you will see this view:
<a href="http://starahead.com/learning/media/2/20060509-gcal03.jpg">Google Calendar view</a>
Where you can change the big view on the right hand side by selecting the available type of view - day,week,month or next 4 days. You can move to different month/week/day (depending on your calendar view type) by clicking the left/right arrow as shown on the picture above.
<p>
One interesting feature this calendar have is you can actually use the small calendar view on the left hand-side to select what you want to see at the calendar big view on the right hand-side. You can do that by drag the mouse on any week at the mini-calendar on the left and you should see the right view will follow the selection you made on the left. Below are the sample:
<p>
<a href="http://starahead.com/learning/media/2/20060509-gcal06.jpg">Mini-Calendar Feature</a>
<p>
You can start using the calendar by creating your events, it's very simple, click on any of the day box of the calendar and the "Create Events" balloon will appear and ready to accept your entry.
<p>
<a href="http://starahead.com/learning/media/2/20060509-gcal07.jpg">Create Events</a>
<p>
You can enter your events title and straight away click the "Create Events" button or you can click on the "edit event details" link to have more control over the entry like duration, reminder etc.
<p>
<a href="http://starahead.com/learning/media/2/20060509-gcal08.jpg">Edit Details Event</a>
<p>
Another nice features are, you can actually drag the mouse over a few days boxes to create a multiple days events like Trainings, exhibitions etc.
<p>
<a href="http://starahead.com/learning/media/2/20060509-gcal09.jpg">Multiple days event</a>
<p>
and of course you can still have the details on this mode.
<p>
<a href="http://starahead.com/learning/media/2/20060509-gcal09b.jpg">Details multiple days event</a>
<p>
Thats all for now, hope you guys enjoy the Google calendar as I do, go further by sharing it with family and friends.
<p>]]></description>
 <category>General</category>
<comments>http://starahead.com/learning/index.php?itemid=24</comments>
 <pubDate>Tue, 9 May 2006 07:49:42 -0700</pubDate>
</item><item>
 <title>Prompt shell: Simple way to rename multiple files</title>
 <link>http://starahead.com/learning/index.php?itemid=22</link>
<description><![CDATA[The situation is you have a number of files with sequence filenames, and you would like to rename it, for example you would like to rename from photos01a.jpg to photos01.jpg, yes, it just a simple removing the 'a' from it, but it would be an annoying jobs if the number of files is quite big.This is the 'before' file listing:
<pre># ls -al
total 106
drwxr-xr-x  2 www  www  1024 Mar 28 10:56 .
drwxr-xr-x  4 www  www   512 Mar 28 09:05 ..
-rw-r--r--  1 www  www  2681 Mar 28 10:56 photos01a.jpg
-rw-r--r--  1 www  www  3033 Mar 28 10:56 photos02a.jpg
-rw-r--r--  1 www  www  2963 Mar 28 10:56 photos03a.jpg
-rw-r--r--  1 www  www  2813 Mar 28 10:56 photos04a.jpg
-rw-r--r--  1 www  www  2879 Mar 28 10:56 photos05a.jpg
-rw-r--r--  1 www  www  2840 Mar 28 10:56 photos06a.jpg
-rw-r--r--  1 www  www  3061 Mar 28 10:56 photos07a.jpg
-rw-r--r--  1 www  www  3200 Mar 28 10:56 photos08a.jpg
-rw-r--r--  1 www  www  2918 Mar 28 10:56 photos09a.jpg
-rw-r--r--  1 www  www  2729 Mar 28 10:56 photos10a.jpg
-rw-r--r--  1 www  www  2753 Mar 28 10:56 photos11a.jpg
-rw-r--r--  1 www  www  2940 Mar 28 10:56 photos12a.jpg
-rw-r--r--  1 www  www  2798 Mar 28 10:56 photos13a.jpg
-rw-r--r--  1 www  www  2595 Mar 28 10:56 photos14a.jpg
-rw-r--r--  1 www  www  2640 Mar 28 10:56 photos15a.jpg
-rw-r--r--  1 www  www  2475 Mar 28 10:56 photos16a.jpg
-rw-r--r--  1 www  www  2907 Mar 28 10:56 photos17a.jpg
-rw-r--r--  1 www  www  2890 Mar 28 10:56 photos18a.jpg
-rw-r--r--  1 www  www  2904 Mar 28 10:56 photos19a.jpg
-rw-r--r--  1 www  www  5507 Mar 28 10:56 photos20a.jpg
-rw-r--r--  1 www  www  5370 Mar 28 10:56 photos21a.jpg
-rw-r--r--  1 www  www  5343 Mar 28 10:56 photos22a.jpg
-rw-r--r--  1 www  www  5576 Mar 28 10:56 photos23a.jpg</pre>

and from the previous article we know that <b>ls -1</b> will gives just the filename output:

<pre># ls -1
photos01a.jpg
photos02a.jpg
photos03a.jpg
photos04a.jpg
photos05a.jpg
photos06a.jpg
photos07a.jpg
photos08a.jpg
photos09a.jpg
photos10a.jpg
photos11a.jpg
photos12a.jpg
photos13a.jpg
photos14a.jpg
photos15a.jpg
photos16a.jpg
photos17a.jpg
photos18a.jpg
photos19a.jpg
photos20a.jpg
photos21a.jpg
photos22a.jpg
photos23a.jpg</pre>

This is what I do:

First I will make sure my shell is Bourne, if not, just run <b>sh</b> to get the Bourne shell.

<pre># <b>env | grep SHELL</b>
SHELL=/bin/csh
# <b>sh</b>
</pre>

Then, use the output of <b>ls -1</b> with the <b>for</b> loop in Bourne shell to execute the <b>mv</b> (move/rename) command. Here I use the <b>sed</b> command to do the online text replacement to the filename entry.

<pre># <b>for i in `ls -1`</b>
> <b>do</b>
> <b>mv $i `echo $i | sed 's/a.jpg/.jpg/g'`</b>
> <b>done</b>
# </pre>

That's it, doesn't matter how many files you have, the looping will take care of it in just a few seconds.

This is the 'after' file listing:

<pre># <b>ls -la</b>
total 104
drwxr-xr-x  2 www  www  1024 Mar 28 11:07 .
drwxr-xr-x  4 www  www   512 Mar 28 09:05 ..
-rw-r--r--  1 www  www  2681 Mar 28 10:56 photos01.jpg
-rw-r--r--  1 www  www  3033 Mar 28 10:56 photos02.jpg
-rw-r--r--  1 www  www  2963 Mar 28 10:56 photos03.jpg
-rw-r--r--  1 www  www  2813 Mar 28 10:56 photos04.jpg
-rw-r--r--  1 www  www  2879 Mar 28 10:56 photos05.jpg
-rw-r--r--  1 www  www  2840 Mar 28 10:56 photos06.jpg
-rw-r--r--  1 www  www  3061 Mar 28 10:56 photos07.jpg
-rw-r--r--  1 www  www  3200 Mar 28 10:56 photos08.jpg
-rw-r--r--  1 www  www  2918 Mar 28 10:56 photos09.jpg
-rw-r--r--  1 www  www  2729 Mar 28 10:56 photos10.jpg
-rw-r--r--  1 www  www  2753 Mar 28 10:56 photos11.jpg
-rw-r--r--  1 www  www  2940 Mar 28 10:56 photos12.jpg
-rw-r--r--  1 www  www  2798 Mar 28 10:56 photos13.jpg
-rw-r--r--  1 www  www  2595 Mar 28 10:56 photos14.jpg
-rw-r--r--  1 www  www  2640 Mar 28 10:56 photos15.jpg
-rw-r--r--  1 www  www  2475 Mar 28 10:56 photos16.jpg
-rw-r--r--  1 www  www  2907 Mar 28 10:56 photos17.jpg
-rw-r--r--  1 www  www  2890 Mar 28 10:56 photos18.jpg
-rw-r--r--  1 www  www  2904 Mar 28 10:56 photos19.jpg
-rw-r--r--  1 www  www  5507 Mar 28 10:56 photos20.jpg
-rw-r--r--  1 www  www  5370 Mar 28 10:56 photos21.jpg
-rw-r--r--  1 www  www  5343 Mar 28 10:56 photos22.jpg
-rw-r--r--  1 www  www  5576 Mar 28 10:56 photos23.jpg
#</pre>]]></description>
 <category>Unix/Linux</category>
<comments>http://starahead.com/learning/index.php?itemid=22</comments>
 <pubDate>Mon, 27 Mar 2006 20:08:36 -0800</pubDate>
</item><item>
 <title>Basic Home Broadband setup</title>
 <link>http://starahead.com/learning/index.php?itemid=21</link>
<description><![CDATA[With the broadband coverage is now widely available, more and more people are started to setup  small network at home. Dad have their own PC, mom using the laptop with wireless G and kids learning and accessing the internet using wireless.Not going to write much on this as the information is widely available on the net already, just to show a start-up setup for a totally beginner - just like how I started.
<p>
Below is my current small network at home:
<p>
<center><a href="http://starahead.com/learning/media/2/20060325-broadband1.gif">Basic broadband network</a></center>
<p>
The modem+AP router that I use is Aztech DSL600EW have 4 UTP ports and a wireless G AP, and also a good web-based management software inside where you do all the internet access settings - including access-on-demand setting.
<p>
The other option you can have is a separate device, 1 broadband modem, 1 AP router, 1 hub/switch and the rest are your PC and notebooks, but this will require more settings - 1 for the modem (if it has a web-based will be good, if not then you have to configure it thru AP router or PC), and another setting for the AP router. With the combo device like Aztech DSL600EW, you just do one setting.



]]></description>
 <category>Networking</category>
<comments>http://starahead.com/learning/index.php?itemid=21</comments>
 <pubDate>Sat, 25 Mar 2006 03:58:14 -0800</pubDate>
</item><item>
 <title>Prompt shell: Basic sed command</title>
 <link>http://starahead.com/learning/index.php?itemid=19</link>
<description><![CDATA[<b>sed</b> stand for <b>S</b>tream <b>ED</b>itor. It is more to ascii text manipulation, but this time while it's from the command line instead of in the text editor like <b>vi</b>. The replace command looks exactly as the <b>vi</b> editor replace command.Normally I would use it with the pipe (<b>|</b>) to filter the output of the previous executed command. For example, I want to capture the output of my file listing into a file for training purposes. I would do something like this:<br />
<pre>$ <b>ls -la > out1.txt</b><br>$ <b>cat out1.txt</b><br>total 24<br>drwx------    2 rosley   users        4096 Feb 21 14:37 ./<br>drwx-----x   14 rosley   users        4096 Feb 21 14:37 ../<br>-rw-------    1 rosley   users          36 Feb 21 14:36 file1.txt<br>-rw-------    1 rosley   users          60 Feb 21 14:37 file2.txt<br>-rw-------    1 rosley   users         144 Feb 21 14:37 file3.txt<br>-rw-------    1 rosley   users          96 Feb 21 14:37 file4.txt<br></pre><br />
But I don't want to publish my username in the output listing, I would like to if possible replace it with some other username. I have 2 choices, 1st is the typical way, use the <i>find and replace</i> function in the vi editor or 2nd choice is by straight away filter it out during the capturing process.<br />
<pre>$ <b>ls -la | sed 's/<i>rosley</i>/<i>user1</i>/' > out1.txt</b><br>$ <b>cat out1.txt</b><br>total 24<br>drwx------    2 user1   users        4096 Feb 21 14:37 ./<br>drwx-----x   14 user1   users        4096 Feb 21 14:37 ../<br>-rw-------    1 user1   users          36 Feb 21 14:36 file1.txt<br>-rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br>-rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br>-rw-------    1 user1   users          96 Feb 21 14:37 file4.txt<br></pre><br />
This is how the above process works, first it will run the <b>ls -al</b> command, then the pipe (<b>|</b>) will cause the output of earlier command (<b>ls -al</b>) been transferred as an input for the next command which is the <b>sed</b> command.<br />
<br />
In this example, we use sed to find the word <i>rosley</i> in every line and replace it with <i>user1</i>, and finally redirect the output into out1.txt file. Now lets take a look at the <b>sed</b> option that we use in the above example: <b>'s/rosley/user1/'</b>. The <b>s</b> stand for <i>substitute</i>, the slash will separate the string that we want to find and the replacement string. <br />
<br />
The <b>'s/string1/string2/'</b> will only replace the first string that matches the <i>string1</i> in every line, if there are more than one appearance of <i>string1</i> in the line, only the first one will be replaced with <i>string2</i>. If it is your intention to replace all the <i>string1</i> with <i>string2</i>, then you should use the <b>global</b> option, like this: <b>'s/string1/string2/g'</b>. This will replace all the <i>string1</i> with <i>string2</i> indefinitely.<br />
<br />
Another option available are the <b>-e</b> which allow us to have multiple <i>find and replace</i> capability in single command. Example below shows how we can replace the owner column (from <i>rosley</i> to <i>user1</i>) and the group column (from <i>users</i> to <i>staff</i>).
<pre>
$ ls -la | sed -e 's/rosley/user1/'  -e 's/users/staff/g' > out1.txt
$ cat out1.txt
total 24
drwx------    2 user1   staff        4096 Feb 21 14:37 ./
drwx-----x   14 user1   staff        4096 Feb 21 14:37 ../
-rw-------    1 user1   staff          36 Feb 21 14:36 file1.txt
-rw-------    1 user1   staff          60 Feb 21 14:37 file2.txt
-rw-------    1 user1   staff         144 Feb 21 14:37 file3.txt
-rw-------    1 user1   staff          96 Feb 21 14:37 file4.txt
</pre>
Later we will use it with the <b>awk</b> command.<br />
 <br />
]]></description>
 <category>Unix/Linux</category>
<comments>http://starahead.com/learning/index.php?itemid=19</comments>
 <pubDate>Fri, 17 Mar 2006 07:48:18 -0800</pubDate>
</item><item>
 <title>Prompt Shell: Modify and execute previous command</title>
 <link>http://starahead.com/learning/index.php?itemid=18</link>
<description><![CDATA[Been long time since I used this command, only today I had a chance to try it again, and to my surprise it still works ! Previously I use this under SUN Solaris unix, it still works when I tested it on FreeBSD 5.x.The simplest example by executing the <b>ls -al</b> command:<br />
<pre>user1% <b>ls -al</b><br>total 24<br>drwx------    2 user1   users        4096 Feb 21 14:37 ./<br>drwx-----x   14 user1   users        4096 Feb 21 14:37 ../<br>-rw-------    1 user1   users          36 Feb 21 14:36 file1.txt<br>-rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br>-rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br>-rw-------    1 user1   users          96 Feb 21 14:37 file4.txt<br></pre><br />
lets just say we would like to execute <b>ls</b> command again but this time we want a different option, instead of <b>-al</b> which gaves a long listing, we just want a simple output of the filenames only. This can be done by using the <b>-1</b> option in <b>ls</b> command. So we know that previous command is <b>ls -al</b>, and next we want to run <b>ls -1</b>, the only different is in the option, just replace the <b>-al</b> with the <b>-1</b>.<br />
<br />
Try this:<br />
<pre>user1% <b>ls -al</b><br>total 24<br>drwx------    2 user1   users        4096 Feb 21 14:37 ./<br>drwx-----x   14 user1   users        4096 Feb 21 14:37 ../<br>-rw-------    1 user1   users          36 Feb 21 14:36 file1.txt<br>-rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br>-rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br>-rw-------    1 user1   users          96 Feb 21 14:37 file4.txt<br>user1% <b>^al^1</b><br>ls -1<br>file1.txt<br>file2.txt<br>file3.txt<br>file4.txt<br>user1%<br></pre><br />
We use the upper-caret character (^) to first specify the word/characters from previous commands that we wanted to be replaced, and then the new word/characters that we want to replace it with. As simple as that.]]></description>
 <category>Unix/Linux</category>
<comments>http://starahead.com/learning/index.php?itemid=18</comments>
 <pubDate>Fri, 17 Mar 2006 06:27:00 -0800</pubDate>
</item><item>
 <title>Shell prompt: Basic find command</title>
 <link>http://starahead.com/learning/index.php?itemid=17</link>
<description><![CDATA[In windows environment you will just have to open the search window, input what you want to search/find and then click the search button. In unix/linux environment, if you're using the X windows system, you might have that capability, but for a faster action, I always prefer the terminal/shell prompt.The simple syntax for the <b>find</b> command is:<br />
<pre><br />
<b>find path-name-list expression</b><br />
</pre><br />
and the simple example will be:<br />
<pre>admin# <b>find /etc -name "host*" -print</b><br>/etc/hosts<br>/etc/net/ticlts/hosts<br>/etc/net/ticots/hosts<br>/etc/net/ticotsord/hosts<br>/etc/hostname.le0<br>/etc/hosts.old<br>/etc/hostname.le1<br>admin#<br></pre><br />
Where:<br />
<pre>find /etc -name "host*" -print<br>find - the command<br>/etc - Where you want it to search<br>-name "host*" - what you want it to search<br>-print - just print the output on screen</pre><br />
I'll try to bring more example and usage of the <b>find </b>command in the later topics.<br />
<br />
Happy searching.]]></description>
 <category>Unix/Linux</category>
<comments>http://starahead.com/learning/index.php?itemid=17</comments>
 <pubDate>Sun, 12 Mar 2006 18:07:07 -0800</pubDate>
</item><item>
 <title>Shell Prompt: Basic Links</title>
 <link>http://starahead.com/learning/index.php?itemid=16</link>
<description><![CDATA[Links is a way to replicate a file and share it with other users (of course with a proper permission applied). Any changes made to any of the link files, all will be affected. This was used last time during software programming development on unix (and yes that will be &gt;10 years ago, vi is the best editor and cobol was widely used).Example will be, you have just created one common C functions file which other programmers might want to call from their programs and they can modify/add a new functions later. What you can do is make a link of this library file and move the linked file to other programmers folders that want to use it, so any changes made all will be updated, and if you accidentally deleted one of the linked file, you can just make another one. The Bad thing is when someone accidentally mess the contents of the file, everybody will get the same ! so in this case Backup is the only solution then.<br />
<br />
Lets go to our sample working folders, <b>ls -il</b> will display the inode information of the files, as the only clue that the file is linked is by looking at their inode number. The same inode number indicate that it is the same file or it is a link. <br />
<pre>user1$ ls -il<br>total 16<br> <b>917508</b> -rw-------    <b>1</b> user1   users          36 Feb 21 14:36 file1.txt<br> <b>917509</b> -rw-------    <b>1</b> user1   users          60 Feb 21 14:37 file2.txt<br> <b>917510</b> -rw-------    <b>1</b> user1   users         144 Feb 21 14:37 file3.txt<br> <b>917511</b> -rw-------    <b>1</b> user1   users          96 Feb 21 14:37 file4.txt<br>user1$</pre><br />
<br />
In the example above the inode number is the left-most number and another thing you can check later is the number at column 3, in this case is 1 - later we will see more on this.<br />
<br />
Syntax for link command is:<br />
<pre><font size=+1>ln sourcefile targetfile</font></pre><br />
<br />
Lets make a link of file1.txt <br />
<pre>user1$ ln file1.txt file1_copy.txt</pre><br />
<br />
Now check the inode number for file1.txt and file1_copy.txt, it sharing the same number ! and the number in the column 3 is now 2 indicating that it has 2 files now with the same inode number.<br />
<pre>user1$ ls -il<br>total 20<br> <b>917508</b> -rw-------    <b>2</b> user1   users          36 Feb 21 14:36 file1.txt<br> <b>917508</b> -rw-------    <b>2</b> user1   users          36 Feb 21 14:36 file1_copy.txt<br> 917509 -rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt</pre><br />
<br />
Now lets append some new line to the file1.txt (observe the changes in filesize of both files).<br />
<pre>user1$ echo "I just appended this line" &gt;&gt; file1.txt<br>user1$ ls -il<br>total 20<br> 917508 -rw-------    2 user1   users          <b>62</b> Mar  2 08:41 file1.txt<br> 917508 -rw-------    2 user1   users          <b>62</b> Mar  2 08:41 file1_copy.txt<br> 917509 -rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt</pre><br />
and also a new line for file1_copy.txt (observe the changes in filesize of both files)<br />
<pre>user1$ echo "I just appended this line 2" &gt;&gt; file1_copy.txt<br>user1$ ls -il<br>total 20<br> 917508 -rw-------    2 user1   users          <b>90</b> Mar  2 08:41 file1.txt<br> 917508 -rw-------    2 user1   users          <b>90</b> Mar  2 08:41 file1_copy.txt<br> 917509 -rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt</pre><br />
Now lets see the contents of both files.<br />
<pre>user1$ cat file1.txt<br>file1<br>file1<br>file1<br>file1<br>file1<br>file1<br>I just appended this line<br>I just appended this line 2<br>user1$<br>user1$ cat file1_copy.txt<br>file1<br>file1<br>file1<br>file1<br>file1<br>file1<Br>I just appended this line<br>I just appended this line 2</pre><br />
As expected, both will have the same contents. Any changes made to any of the files will affects all.<br />
<br />
Deleting one of the link files will affects the other.<br />
<pre>user1$ ln file1.txt file1_copy2.txt<br>user1$ ls -il<br>total 20<br> 917508 -rw-------    3 user1   users          36 Feb 21 14:36 file1.txt<br> 917508 -rw-------    3 user1   users          36 Feb 21 14:36 file1_copy.txt<br> 917508 -rw-------    3 user1   users          36 Feb 21 14:36 file1_copy2.txt<br> 917509 -rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt<br>user1$ rm file1_copy2.txt<br>user1$ ls -il<br>total 20<br> 917508 -rw-------    3 user1   users          36 Feb 21 14:36 file1.txt<br> 917508 -rw-------    3 user1   users          36 Feb 21 14:36 file1_copy.txt<br> 917509 -rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt</pre><br />
<br />
You cannot do a link on directory.<br />
<pre>user1$ ln tmp2 tmp3<br>ln: `tmp2': hard link not allowed for directory<br></pre><br />
<br />
<b><font size=+1>Symbolic links</font></b><br />
<br />
Syntax for symbolic link command is:<br />
<pre><font size=+1>ln -s sourcefile targetfile</font></pre><br />
<br />
Symbolic links is more to shortcut in windows than link, all it does basically just redirect it to the original file. The inode number of the symbolic link is different from the source.<br />
<pre>user1$ ln -s file2.txt file2_copy.txt<br>user1$ ls -il<br>total 20<Br> 917508 -rw-------    2 user1   users          36 Feb 21 14:36 file1.txt<br> 917508 -rw-------    2 user1   users          36 Feb 21 14:36 file1_copy.txt<br> <b>917509</b> -rw-------    <b>1</b> user1   users          60 Feb 21 14:37 file2.txt<br> <b>917563</b> lrwxrwxrwx    <b>1</b> user1   users           9 Mar  2 08:39 file2_copy.txt -&gt; file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt</pre><br />
Deleting the symbolic link file will not affecting the source file.<br />
<pre>user1$ rm file2_copy.txt<br>user1$ ls -il<br>total 20<br> 917508 -rw-------    2 user1   users          36 Feb 21 14:36 file1.txt<br> 917508 -rw-------    2 user1   users          36 Feb 21 14:36 file1_copy.txt<br> 917509 -rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt</pre><br />
Lets re-create the symbolic link file and then this time try delete the source file instead.<br />
<pre>user1$ ln -s file2.txt file2_copy.txt<br>user1$ ls -il<br>total 20<br> 917508 -rw-------    2 user1   users          90 Mar  2 08:41 file1.txt<br> 917508 -rw-------    2 user1   users          90 Mar  2 08:41 file1_copy.txt<br> 917509 -rw-------    1 user1   users          60 Feb 21 14:37 file2.txt<br> 917563 lrwxrwxrwx    1 user1   users           9 Mar  2 08:42 file2_copy.txt -&gt; file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt<br>user1$ rm file2.txt<br>user1$ ls -il<br>total 16<br> 917508 -rw-------    2 user1   users          90 Mar  2 08:41 file1.txt<br> 917508 -rw-------    2 user1   users          90 Mar  2 08:41 file1_copy.txt<br> 917563 lrwxrwxrwx    1 user1   users           9 Mar  2 08:42 file2_copy.txt -&gt; file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt<br>user1$ cat file2_copy.txt<br>cat: file2_copy.txt: No such file or directory<br>user1$</pre><br />
When you delete the source file, all the symbolic link file will be useless as its now redirecting to a file that doesn't exists.<br />
<br />
You can create a symbolic link of folder/directory, this is very helpful as you can create shortcut for a long sub-folders. <br />
<pre>user1$ mkdir tmp2<br>user1$ ln -s tmp2 tmp3<br>user1$ ls -il<br>total 24<br> 917508 -rw-------    3 user1   users          90 Mar  2 08:41 file1.txt<br> 917508 -rw-------    3 user1   users          90 Mar  2 08:41 file1_copy.txt<br> 917508 -rw-------    3 user1   users          90 Mar  2 08:41 file1_copy2.txt<br> 917563 lrwxrwxrwx    1 user1   users           9 Mar  2 08:42 file2_copy.txt -> file2.txt<br> 917510 -rw-------    1 user1   users         144 Feb 21 14:37 file3.txt<br> 917511 -rw-------    1 user1   users          96 Feb 21 14:37 file4.txt<br>2228384 drwx------    2 user1   users        4096 Mar  2 08:51 tmp2/<br> 917509 lrwxrwxrwx    1 user1   users           4 Mar  2 08:51 tmp3 -&gt; tmp2/<br>user1$</pre><br />
<br />
]]></description>
 <category>Unix/Linux</category>
<comments>http://starahead.com/learning/index.php?itemid=16</comments>
 <pubDate>Wed, 1 Mar 2006 21:56:32 -0800</pubDate>
</item>
  </channel>
</rss>
