<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.linuxquestions.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ajs318</id>
	<title>LQWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.linuxquestions.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ajs318"/>
	<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/wiki/Special:Contributions/Ajs318"/>
	<updated>2026-04-15T12:54:40Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.0</generator>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Office_tasks&amp;diff=22043</id>
		<title>Office tasks</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Office_tasks&amp;diff=22043"/>
		<updated>2004-11-05T21:26:36Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: /* Word processing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Office tasks =&lt;br /&gt;
Most [[distribution]]s include at least two [[office suite]]s: [http://openoffice.org OpenOffice.org] and one of [http://www.koffice.org/ KOffice] or [http://www.gnome.org/gnome-office/ GNOME Office]; major distributions include all three of them and probably some more. Suffice it to say that these are the three most important ones.&lt;br /&gt;
&lt;br /&gt;
== Word processing ==&lt;br /&gt;
* OpenOffice.org brings [[OpenWriter]]&lt;br /&gt;
* GNOME Office has [[AbiWord]]&lt;br /&gt;
* KOffice has [[KWord]]&lt;br /&gt;
While you're word proceessing, you may also have to type [[Accented Characters]].  This guide shows you how.&lt;br /&gt;
&lt;br /&gt;
== Spreadsheets ==&lt;br /&gt;
* OpenOffice.org has [[OpenCalc]]&lt;br /&gt;
* GNOME Office has [[Gnumeric]]&lt;br /&gt;
* KOffice has [[KSpread]]&lt;br /&gt;
&lt;br /&gt;
== Presentations and drawing ==&lt;br /&gt;
&lt;br /&gt;
* OpenOffice.org has [[Impress]] and [[Draw]]&lt;br /&gt;
* GNOME Office has [[Dia]], [[Sodipodi]], [[Skencil]] and [[GIMP]]&lt;br /&gt;
* KOffice has [[KPresenter]], [[Kivio]] and [[Karbon14]]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Talk:Accented_Characters&amp;diff=25246</id>
		<title>Talk:Accented Characters</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Talk:Accented_Characters&amp;diff=25246"/>
		<updated>2004-11-05T21:23:37Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I've been using Linux full-time for more than two years, and I've only discovered this today.&lt;br /&gt;
&lt;br /&gt;
I wasn't really sure where to put this page, but I linked it from &amp;quot;common tasks&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[User:Ajs318|AJS]]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Accented_Characters&amp;diff=25245</id>
		<title>Accented Characters</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Accented_Characters&amp;diff=25245"/>
		<updated>2004-11-05T21:18:18Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: First version&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Typing Accented and other &amp;quot;foreign language&amp;quot; Characters==&lt;br /&gt;
&lt;br /&gt;
A range of '''accented and other foreign-language characters''' are available using the &amp;quot;Alt Gr&amp;quot; key on a standard PC keyboard.  (Note than not all fonts include a full set of accented characters).&lt;br /&gt;
&lt;br /&gt;
Some characters are produced in two keystrokes:  the first indicates that the following character is to be accented, and the second is the character to which the accent is to be applied.  The two-stroke keys are ;, ', #, [, ] and =.&lt;br /&gt;
* Alt Gr + ; applies an acute  (forward-leaning)  accent to the next vowel:  á é í ó ú Á É Í Ó Ú.&lt;br /&gt;
* Alt Gr + ' applies a circumflex  (hat)  accent to the next vovel:  â ê î ô û Â Ê Î Ô Û.&lt;br /&gt;
* Alt Gr + # applies a grave  (backward-leaning)  accent to the next vowel:  à è ì ò ù À È Ì Ò Ù.&lt;br /&gt;
* Alt Gr + [ applies an umlaut or diaeresis  (two dots)  to the next vowel:  ä ë ï ö ü Ä E Ï Ö Ü.&lt;br /&gt;
* Alt Gr + ] applies a tilde to the next A, N or O:  ã ñ õ Ã Ñ Õ.&lt;br /&gt;
* Alt Gr + = applies a tail under the next C or S: ç ş Ç Ş&lt;br /&gt;
* Alt Gr + shift + [ applies a ring to the next A: å Å&lt;br /&gt;
&lt;br /&gt;
You can check what accent a key produces by pressing it twice.&lt;br /&gt;
&lt;br /&gt;
Other characters are produced using a single keystroke.  The diagram below shows the relationship between each key and the characters it produces  (top row is shifted):&lt;br /&gt;
&lt;br /&gt;
 | ¡ ⅛ £ ¼ ⅜ ⅝ ⅞ ™ ± ° ¿ ˛&lt;br /&gt;
 | ¹ ² ³ € ½ ¾ { [ ] } \ ¸&lt;br /&gt;
 ` 1 2 3 4 5 6 7 8 9 0 - =&lt;br /&gt;
&lt;br /&gt;
   Ω Ł E ® Ŧ ¥ ↑ ı Ø Þ ˚ ¯&lt;br /&gt;
   @ ł e ¶ ŧ ← ↓ → ø þ &amp;quot; ~&lt;br /&gt;
   Q W E R T Y U I O P [ ]&lt;br /&gt;
&lt;br /&gt;
   Æ § Ð ª Ŋ Ħ J &amp;amp; Ł ˝ ˇ ˘&lt;br /&gt;
   æ ß ð đ ŋ ħ j ĸ ł ' ^ `&lt;br /&gt;
   A S D F G H J K L ; ' #&lt;br /&gt;
&lt;br /&gt;
   « » ¢ “ ” n µ   · ˙&lt;br /&gt;
   &amp;lt; &amp;gt; © ` ' N º × ÷ &lt;br /&gt;
   Z X C V B N M , . /&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Common_Tasks&amp;diff=15081</id>
		<title>Common Tasks</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Common_Tasks&amp;diff=15081"/>
		<updated>2004-11-05T20:42:29Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: /* Commands, Connecting, GRUB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Desktop Linux is still under heavy development. While we all wish Linux was so intuitive nobody needed instructions, currently that isn't always the case. This section is meant for '''notes and quick guides''' on how to perform common tasks on Linux. &lt;br /&gt;
&lt;br /&gt;
If a section isn't yet written and you are able to write it, please do so!&lt;br /&gt;
&lt;br /&gt;
== General user tasks ==&lt;br /&gt;
&lt;br /&gt;
===Productivity===&lt;br /&gt;
====Browsing, Burning, Emailing, Office, Scanning, Viewing====&lt;br /&gt;
* [[Browsing tasks]] - browsing the WWW and downloading safely&lt;br /&gt;
* [[Burning a CDROM]] - some pointers on how to write CDs.&lt;br /&gt;
* [[Emailing tasks]] - sending and receiving emails, setting up different mail applications&lt;br /&gt;
* [[Office tasks]] - word processing, spreadsheet, presentation, image manipulation and other&lt;br /&gt;
* [[Scanning]] - use a [[Scanner]] to convert you paper documents or images to an electronic format&lt;br /&gt;
* [[Viewing files]] - various ways to view the contents of files&lt;br /&gt;
&lt;br /&gt;
===Fun===&lt;br /&gt;
====Gaming, Multimedia, Talking====&lt;br /&gt;
* [[Gaming]] - pass some time, ''not'' working&lt;br /&gt;
* [[Multimedia tasks]] - listen to music, extract CDs, watch videos and DVDs&lt;br /&gt;
* [[Talking to friends online]] - how to access common instant messaging networks, see also [[IM]].&lt;br /&gt;
&lt;br /&gt;
===Technical===&lt;br /&gt;
==== Commands, Connecting, GRUB ====&lt;br /&gt;
* [[Command Line User Interface]] - Techniques for better experience&lt;br /&gt;
* [[Accented Characters]] - how to type accented characters&lt;br /&gt;
* [[Set up modem]] - using your modem/network connection to get online&lt;br /&gt;
* [[GRUB Menu]] - Single Task - Removing  old kernel entries from your GRUB Menu boot up selections.&lt;br /&gt;
* [http://home.gagme.com/greg/linux/usbcamera.php How to Connect a Digital Camera to Linux (external link)] - an excellent how-to on connecting digital cameras to Linux.&lt;br /&gt;
* [[Installing Software]] - how to find and manage additional software on a running Linux system&lt;br /&gt;
* [[Installing Windows fonts]] - installing your Windows fonts so they work with your Linux install.&lt;br /&gt;
* [[screenshots|Taking screenshots]] - You want to show somebody your desktop? There are tools that will help you make a [[screenshots | screenshot]] and [[record your desktop]] so that you can send movie-files of how nice your desktop looks.&lt;br /&gt;
* [[Running Windows software]] - for that simply must-have program&lt;br /&gt;
&lt;br /&gt;
== Power user tasks ==&lt;br /&gt;
=== Compiling kernel, Configure, IRC help, GRUB, Drivers, Recover, Remote connection ===&lt;br /&gt;
&lt;br /&gt;
* [[Compiling a Kernel]] - here is a guide for compiling a kernel&lt;br /&gt;
* [[Configure Storage Devices]] - how to partition a hard drive, add a new hard drive, use software RAID, or use LVM (logical volume management).&lt;br /&gt;
* [[Creating startup scripts]] - scripts that automatically run when the computer starts&lt;br /&gt;
* [[Getting help from IRC]] - LinuxQuestions is a great forum, but it isn't the only one. If you know how, the IRC chat networks can also be a useful resource.&lt;br /&gt;
* [[GRUB boot menu]] - Configuration Guide.&lt;br /&gt;
* [[Installing NVIDIA drivers]] - Information on installing the newer (but closed-source) drivers released by NVIDIA. These drivers are sometimes required to run some games, like Unreal or Quake.&lt;br /&gt;
* [[Recover a Terminal Session]] - What to do if your screen's garbaged.&lt;br /&gt;
* [[Remote Desktop Connection|Access your System Remotely]] - Access your Linux system from another computer (running Linux, or some other OS) or use your Linux box to access another computer (running Linux, or some other OS).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Distro specific ===&lt;br /&gt;
* [[Distro specific tips &amp;amp; tricks]]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Common_Tasks&amp;diff=13761</id>
		<title>Common Tasks</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Common_Tasks&amp;diff=13761"/>
		<updated>2004-11-05T20:42:00Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: /* Commands, Connecting, GRUB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Desktop Linux is still under heavy development. While we all wish Linux was so intuitive nobody needed instructions, currently that isn't always the case. This section is meant for '''notes and quick guides''' on how to perform common tasks on Linux. &lt;br /&gt;
&lt;br /&gt;
If a section isn't yet written and you are able to write it, please do so!&lt;br /&gt;
&lt;br /&gt;
== General user tasks ==&lt;br /&gt;
&lt;br /&gt;
===Productivity===&lt;br /&gt;
====Browsing, Burning, Emailing, Office, Scanning, Viewing====&lt;br /&gt;
* [[Browsing tasks]] - browsing the WWW and downloading safely&lt;br /&gt;
* [[Burning a CDROM]] - some pointers on how to write CDs.&lt;br /&gt;
* [[Emailing tasks]] - sending and receiving emails, setting up different mail applications&lt;br /&gt;
* [[Office tasks]] - word processing, spreadsheet, presentation, image manipulation and other&lt;br /&gt;
* [[Scanning]] - use a [[Scanner]] to convert you paper documents or images to an electronic format&lt;br /&gt;
* [[Viewing files]] - various ways to view the contents of files&lt;br /&gt;
&lt;br /&gt;
===Fun===&lt;br /&gt;
====Gaming, Multimedia, Talking====&lt;br /&gt;
* [[Gaming]] - pass some time, ''not'' working&lt;br /&gt;
* [[Multimedia tasks]] - listen to music, extract CDs, watch videos and DVDs&lt;br /&gt;
* [[Talking to friends online]] - how to access common instant messaging networks, see also [[IM]].&lt;br /&gt;
&lt;br /&gt;
===Technical===&lt;br /&gt;
==== Commands, Connecting, GRUB ====&lt;br /&gt;
* [[Command Line User Interface]] - Techniques for better experience&lt;br /&gt;
* [[AAccented Characters]] - how to type accented characters&lt;br /&gt;
* [[Set up modem]] - using your modem/network connection to get online&lt;br /&gt;
* [[GRUB Menu]] - Single Task - Removing  old kernel entries from your GRUB Menu boot up selections.&lt;br /&gt;
* [http://home.gagme.com/greg/linux/usbcamera.php How to Connect a Digital Camera to Linux (external link)] - an excellent how-to on connecting digital cameras to Linux.&lt;br /&gt;
* [[Installing Software]] - how to find and manage additional software on a running Linux system&lt;br /&gt;
* [[Installing Windows fonts]] - installing your Windows fonts so they work with your Linux install.&lt;br /&gt;
* [[screenshots|Taking screenshots]] - You want to show somebody your desktop? There are tools that will help you make a [[screenshots | screenshot]] and [[record your desktop]] so that you can send movie-files of how nice your desktop looks.&lt;br /&gt;
* [[Running Windows software]] - for that simply must-have program&lt;br /&gt;
&lt;br /&gt;
== Power user tasks ==&lt;br /&gt;
=== Compiling kernel, Configure, IRC help, GRUB, Drivers, Recover, Remote connection ===&lt;br /&gt;
&lt;br /&gt;
* [[Compiling a Kernel]] - here is a guide for compiling a kernel&lt;br /&gt;
* [[Configure Storage Devices]] - how to partition a hard drive, add a new hard drive, use software RAID, or use LVM (logical volume management).&lt;br /&gt;
* [[Creating startup scripts]] - scripts that automatically run when the computer starts&lt;br /&gt;
* [[Getting help from IRC]] - LinuxQuestions is a great forum, but it isn't the only one. If you know how, the IRC chat networks can also be a useful resource.&lt;br /&gt;
* [[GRUB boot menu]] - Configuration Guide.&lt;br /&gt;
* [[Installing NVIDIA drivers]] - Information on installing the newer (but closed-source) drivers released by NVIDIA. These drivers are sometimes required to run some games, like Unreal or Quake.&lt;br /&gt;
* [[Recover a Terminal Session]] - What to do if your screen's garbaged.&lt;br /&gt;
* [[Remote Desktop Connection|Access your System Remotely]] - Access your Linux system from another computer (running Linux, or some other OS) or use your Linux box to access another computer (running Linux, or some other OS).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Distro specific ===&lt;br /&gt;
* [[Distro specific tips &amp;amp; tricks]]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Apachectl&amp;diff=12832</id>
		<title>Apachectl</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Apachectl&amp;diff=12832"/>
		<updated>2004-08-24T10:18:07Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: configtest&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Apachectl''' allows control over the [[httpd]] [[daemon]].&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
(this is not exhaustive, please see &amp;lt;tt&amp;gt;man apachectl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
:&amp;lt;tt&amp;gt;# apachectl start&amp;lt;/tt&amp;gt; - starts httpd.  Normally this would go somewhere in your initialisation scripts.&lt;br /&gt;
:&amp;lt;tt&amp;gt;# apachectl stop&amp;lt;/tt&amp;gt; - stops httpd.  You might need this if you get runaway processes, or if someone is trying to DDoS you; or if you plan to do a lot of web server maintenance.&lt;br /&gt;
:&amp;lt;tt&amp;gt;# apachectl restart&amp;lt;/tt&amp;gt; - restarts httpd and re-reads the configuration.  (This actually just sends SIGHUP to the main process; SIGHUP is often used to instruct daemons to restart themselves.  You can use &amp;lt;tt&amp;gt;kill -HUP&amp;lt;/tt&amp;gt; as an alternative, if you really want.)&lt;br /&gt;
:&amp;lt;tt&amp;gt;# apachectl graceful&amp;lt;/tt&amp;gt; - this does a &amp;quot;graceful restart&amp;quot;, allowing any transfers in progress to complete, but still re-reads the configuration and applies it to future transfers.  (This uses SIGUSR1.)  Use this after editing the configuration.&lt;br /&gt;
:&amp;lt;tt&amp;gt;# apachectl configtest&amp;lt;/tt&amp;gt; - checks the configuration file for anything that would cause httpd to fail.  Use this after editing the configuration and before restarting httpd.  '''Note''':  this only proves that the file makes sense to httpd; it does ''not'' necessarily mean that it does exactly what you were expecting.&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://httpd.apache.org/docs-2.0/programs/apachectl.html Project homepage]&lt;br /&gt;
&lt;br /&gt;
{{msg:stub}}&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Apachectl&amp;diff=11259</id>
		<title>Apachectl</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Apachectl&amp;diff=11259"/>
		<updated>2004-08-24T10:00:38Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: added usage notes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Apachectl''' allows control over the [[httpd]] [[daemon]].&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
(this is not exhaustive, please see &amp;lt;tt&amp;gt;man apachectl&amp;lt;/tt&amp;gt;)&lt;br /&gt;
:&amp;lt;tt&amp;gt;# apachectl start&amp;lt;/tt&amp;gt; - starts httpd.  Normally this would go somewhere in your initialisation scripts.&lt;br /&gt;
:&amp;lt;tt&amp;gt;# apachectl stop&amp;lt;/tt&amp;gt; - stops httpd.  You might need this if you get runaway processes, or if someone is trying to DDoS you; or if you plan to do a lot of web server maintenance.&lt;br /&gt;
:&amp;lt;tt&amp;gt;# apachectl restart&amp;lt;/tt&amp;gt; - restarts httpd and re-reads the configuration.  (This actually just sends SIGHUP to the main process; SIGHUP is often used to instruct daemons to restart themselves.  You can use &amp;lt;tt&amp;gt;kill -HUP&amp;lt;/tt&amp;gt; as an alternative, if you really want.)&lt;br /&gt;
:&amp;lt;tt&amp;gt;# apachectl graceful&amp;lt;/tt&amp;gt; - this does a &amp;quot;graceful restart&amp;quot;, allowing any transfers in progress to complete, but still re-reads the configuration and applies itto future transfers.  (This uses SIGUSR1.)  &lt;br /&gt;
==External links==&lt;br /&gt;
*[http://httpd.apache.org/docs-2.0/programs/apachectl.html Project homepage]&lt;br /&gt;
&lt;br /&gt;
{{msg:stub}}&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Keyboard_shortcuts_at_a_glance&amp;diff=11243</id>
		<title>Keyboard shortcuts at a glance</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Keyboard_shortcuts_at_a_glance&amp;diff=11243"/>
		<updated>2004-08-23T08:16:42Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: Added some commands for pico / nano&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b&amp;gt; Keyboard shortcuts at a glance&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Listed here are some commonly used keyboard shortcuts for various popular [[text editor]]s.  Note, the commands given for [[pico]] should work equally well in [[nano]].  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;How do I&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Check spelling?&amp;lt;/u&amp;gt;    &lt;br /&gt;
**emacs: Alt + $                                 &lt;br /&gt;
**joe: Ctrl + [, n&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Close the window in which cursor is positioned?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Ctrl + x&lt;br /&gt;
**joe: Ctrl + k, i&lt;br /&gt;
**vi: :(colon), w, q  - Press colon, release it and then press w and q. This command save the file and then quits.&lt;br /&gt;
**vi: :(colon), q, !  - Press colon, release it and then press q and !. This command quits without saving the file.&lt;br /&gt;
**pico: Ctrl + X&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Create a new file?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Ctrl + f&lt;br /&gt;
**joe: Ctrl + k, e&lt;br /&gt;
**vi: :(colon), x &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Delete a line?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Ctrl + k&lt;br /&gt;
**joe: Ctrl + j&lt;br /&gt;
**vi: dd &lt;br /&gt;
**pico: Ctrl + A, ctrl + K&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Mark a block of text?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Ctrl + spacebar&lt;br /&gt;
**joe: Ctrl + k, b&lt;br /&gt;
**pico: Ctrl + 6  (or ctrl + ^)&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Move to the beginning of a file?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Home&lt;br /&gt;
**vi: Home&lt;br /&gt;
**pico: Ctrl + W, Ctrl + Y&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Open a file?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Ctrl + v&lt;br /&gt;
**joe: Ctrl + k, e&lt;br /&gt;
**vi: :(colon), e&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Reformat the text after an editing change?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Alt + q&lt;br /&gt;
**joe: Ctrl + r&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Save a file?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Ctrl + s&lt;br /&gt;
**joe: Ctrl + k, d&lt;br /&gt;
**vi: :(colon), w&lt;br /&gt;
**pico: Ctrl + O&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Scroll down?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: PgDn&lt;br /&gt;
**joe: PgDn&lt;br /&gt;
**vi: j or down arrow (move down one line), PgDn or Ctrl + f (move down one page)&lt;br /&gt;
**pico: Ctrl + N (move one line), Ctrl + V (move one page)&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Scroll up?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: PgUp&lt;br /&gt;
**joe: PgUp&lt;br /&gt;
**vi: k or up arrow (move up one line), PgUp or Ctrl + b (move up one page)&lt;br /&gt;
**pico: Ctrl + P (move one line), Ctrl + Y (move one page)&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Search for text?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Ctrl + s&lt;br /&gt;
**joe: Ctrl + k, f&lt;br /&gt;
**vi: / (forward slash), followed by text to search for&lt;br /&gt;
**pico: Ctrl + W&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;See the program's keyboard shotcuts on screen?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: F1&lt;br /&gt;
**joe: Ctrl + k, h&lt;br /&gt;
**vi: F1&lt;br /&gt;
**pico: Ctrl + G&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Split the screen into two windows?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Ctrl + x, 2&lt;br /&gt;
**joe: Ctrl + k, o&lt;br /&gt;
**vi: :(colon), s, p&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Undo an editing change?&amp;lt;/u&amp;gt;&lt;br /&gt;
**emacs: Ctrl + _(Underscore)&lt;br /&gt;
**joe: Ctrl + _(Underscore)&lt;br /&gt;
**vi: :(colon), u&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Talk:Set_up_NTL&amp;diff=19476</id>
		<title>Talk:Set up NTL</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Talk:Set_up_NTL&amp;diff=19476"/>
		<updated>2004-08-22T22:15:58Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sounds like a standard cable modem service. You call what sounds like the cable modem the &amp;quot;settop box&amp;quot;. Does this box allow you to surf the net from you tv, like webtv, or does it just pass through the cable signal to the tv? Or do you need a splitter to hook cable to your tv? If the box ''is'' a standard cable modem, then my experience says, that if it doesn't connect to the internet properly, it should assign a 192.xxx.xxx.xxx ip to whatever computer/nat router is plugged into it. &lt;br /&gt;
&lt;br /&gt;
The lack of linux/intranet support is pretty standard. Most cable companies' internet tech support pretty much consists of a callcenter in India sorting out the stupid calls before sending out a service tech.[[User:Crazyeddie|Crazyeddie]] 16:50, May 25, 2004 (EDT)&lt;br /&gt;
----&lt;br /&gt;
The set-top box is the device that connects to the TV cable; it has two SCART connectors for the TV (RGB and CVBS) and VCR (CVBS only), plus an RF passthrough for an antenna  (cable output available modulated on ch.52 {adjustable via installation menu} but no NICAM).  It also has an ethernet port.  This port provides a single IP address, initially in a 10.x.y.z range.  After an initial &amp;quot;provisioning&amp;quot; operation -- carried out by submitting a HTML form -- a new, routable address is allocated using DHCP.  This address seems to persist for quite awhile  (I've had two in so many years).&lt;br /&gt;
&lt;br /&gt;
You can surf ''part'' of the web on your TV without a computer, using the cable remote; you can also pay a premium for full web access.  You can also send and receive e-mail.  A wireless keyboard is available, so you don't have to enter text one letter at a time like 1980s video games.  But it's quite limited.  [[User:ajs318|ajs318]]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=OpenOffice_Hacking&amp;diff=24734</id>
		<title>OpenOffice Hacking</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=OpenOffice_Hacking&amp;diff=24734"/>
		<updated>2004-08-22T21:50:24Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==OpenOffice.org Hacking==&lt;br /&gt;
&lt;br /&gt;
OpenOffice.org documents are ZIP archives containing several XML (and other) files.  If you know what you are doing, you can create documents in your own programs which can be read by OpenOffice.org applications.&lt;br /&gt;
&lt;br /&gt;
===Why?===&lt;br /&gt;
&lt;br /&gt;
Why would you want to do this?  Well, one use I found was for a web application which -- based on form input and the contents of a [[MySQL]] database -- generates customised documents ready to download straight into OpenOffice.org for printing.  &lt;br /&gt;
&lt;br /&gt;
Another use was for printing my holiday photographs -- I wanted to print out pre-defined layouts, such as two pictures 160x120, or five 80x60 and one 160x20, on a single A4 sheet with guillotine marks.  I did ''not'' want to have to click my way through the file requester and the position-and-size requester for each and every single picture.&lt;br /&gt;
&lt;br /&gt;
And being a [[hacker]] myself, I would need a good reason '''not''' to attempt something like this!&lt;br /&gt;
&lt;br /&gt;
===What With?===&lt;br /&gt;
&lt;br /&gt;
Apart from this document, you will need OpenOffice.org; unzip; zip; and a good [[text editor]].&lt;br /&gt;
&lt;br /&gt;
===How?===&lt;br /&gt;
&lt;br /&gt;
First of all, create any old document you like  (but something you can mess around with)  in OpenOffice.org.  Now, go to an Xterm, and navigate to the directory where you saved the document.  Create a temporary directory and copy your document in there.  Change to the temporary directory and unzip the copy of your document.&lt;br /&gt;
&lt;br /&gt;
There should be a subdirectory called META-INF and depending on the contents of your document, there may be other subdirectories for pictures and other embedded objects.  In META-INF will be a file called &amp;quot;manifest.xml&amp;quot; -- this is important, as it lists all the files which make up the OpenOffice document.  If you split or combine any of the files, you will have to edit this manifest file to reflect any changes that you made.&lt;br /&gt;
&lt;br /&gt;
The real juicy stuff is in a file called content.xml in the main directory.&lt;br /&gt;
&lt;br /&gt;
(todo: expand)&lt;br /&gt;
&lt;br /&gt;
===Hint===&lt;br /&gt;
&lt;br /&gt;
You may find that these XML files have very long lines, with no breaks between the closing &amp;amp;gt; of one tag and the opening &amp;amp;lt; of the next.  Though legitimate XML, it's harder to edit.  Use&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;sed -e's/&amp;amp;gt;&amp;amp;lt;/&amp;amp;gt;\n&amp;amp;lt;/g' foo.xml &amp;amp;gt; foo.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to sort this out.&lt;br /&gt;
&lt;br /&gt;
===Ready to go===&lt;br /&gt;
&lt;br /&gt;
Once you have done the edits you want, zip up the temporary directory and give it a suitable name  (eg.  foo_new.sxw).  Now, try loading it into OpenOffice.org and see what happens!&lt;br /&gt;
&lt;br /&gt;
===Web Drive===&lt;br /&gt;
&lt;br /&gt;
A CGI script needs to give a MIME-type as part of the HTML headers, then a double newline to mark the end of the headers, then finally the ZIPped output.  This does ''not'' need to be base-64 encoded, but can just be in simple 8-bit binary form, since httpd  (which is parsing the output you generate)  will take care of whether the connection is binary-safe or not.&lt;br /&gt;
&lt;br /&gt;
If you are running on a fast server and your clients' timeout is not excessively short, you should have plenty of time to send the headers, generate the zipfile on the fly  (make a directory under /tmp; put your PID in the dirname to keep it unique; build up files in the directory; use a shell command to zip it)  and just dump it to stdout.&lt;br /&gt;
&lt;br /&gt;
(todo: perl example)&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=OpenOffice&amp;diff=11701</id>
		<title>OpenOffice</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=OpenOffice&amp;diff=11701"/>
		<updated>2004-08-22T20:46:21Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: =See Also=&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''OpenOffice.org''' is both an open source product and a project. The product is a multi-platform office productivity suite. It combines the key desktop applications--such as a [[OpenOffice_swriter|word processor]], [[OpenOffice_scalc|spreadsheet]], [[OpenOffice_simpress|presentation manager]],  [[OpenOffice_sdraw|drawing program]],  and [[OpenOffice_sweb|web page design tool]]--with a user interface and feature set similar to other office suites. Sophisticated and flexible, OpenOffice.org also works transparently with a variety of file formats, including those of [[Microsoft Office]]. &lt;br /&gt;
&lt;br /&gt;
Available in 25 languages with more being constantly added by the community, OpenOffice.org runs stably and natively on [[Solaris]], [[Common_Questions_and_Misconceptions#Q:_What_is_Linux?|Linux]] (including PPC Linux), and [[Windows]]. Additional ports, such as for [[FreeBSD]], [[IRIX]], and Mac [[OS X]], are in various stages of completion. &lt;br /&gt;
&lt;br /&gt;
Written in [[C plus plus|C++]] and with documented [[API|APIs]] licensed under the [[LGPL]] and [[SISSL]] Open Source licenses, OpenOffice.org allows any knowledgeable developer to benefit from the source. And because the file format for OpenOffice.org is [[XML]], interoperability is easy, making future development and adoption more certain.&lt;br /&gt;
&lt;br /&gt;
[[SUN]] sells a commercial office suite based on OpenOffice.org,  called [[StarOffice]].  Students can download it free from [http://wwws.sun.com/software/download/desktop_app.html sun.com].&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Openoffice Icon Themes|Customising Appearance]]&lt;br /&gt;
&lt;br /&gt;
* [[Openoffice Hacking]]&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://www.openoffice.org/ The OpenOffice.org homepage]&lt;br /&gt;
**[http://download.openoffice.org/index.html Download page]&lt;br /&gt;
**[http://support.openoffice.org/index.html Support]&lt;br /&gt;
**[http://www.oooforum.org The OpenOffice.org Forum]&lt;br /&gt;
**[http://kde.openoffice.org/ KDE Integration Project]&lt;br /&gt;
*[http://www.gnome.org/projects/ooo/ GNOME/OpenOffice.org]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=C&amp;diff=6673</id>
		<title>C</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=C&amp;diff=6673"/>
		<updated>2004-03-26T20:45:19Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: remembered a bit I forgot before&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''C''' programming language is certainly the most influential in the world of the programming. Created at first by Brian W. Kernighan and Dennis M. Ritchie in 1978, this language is characterized by his closeness to the hardware without being architecture dependent. Not that it is complicated (like Assembly), but you can move generally as you want in the memory for example, but may crash if you are not permitted to read or write to that memory.&lt;br /&gt;
&lt;br /&gt;
The C language is often associated with UNIX, maybe because it has been developed on and written with it. But it is not linked with any system nor architecture. You can use C in many applications with this language. It, however, has come under criticism for being insecure, when it is not used correctly (for example, bounds overflow checking is not done by default - allowing the chance for buffer overflow attacks in poorly written software).&lt;br /&gt;
&lt;br /&gt;
Note that even if it is still the most used, the C language has gradually become an old language. Having been written in 1978 means it was created before many modern studies on programming language theory. These studies provide huge advances in the creation of a language, especially in the precision and speed with which it's compiled. For example, you don't have a real range of lines and columns when there is an error or a warning in C; recent languages do.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==History==&lt;br /&gt;
''(Feed me)''&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Language Features==&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
====Basic Types====&lt;br /&gt;
'''int''': integer&amp;lt;br/&amp;gt;&lt;br /&gt;
'''char''': character&amp;lt;br/&amp;gt;&lt;br /&gt;
'''float''': float&amp;lt;br/&amp;gt;&lt;br /&gt;
'''double''': double float&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''short''': shorter type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''long''': longer type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''signed''': signed type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''unsigned''': unsigned type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===Array and pointers===&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===Structures===&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===User-defined Types=== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--====Constants====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Expressions===&lt;br /&gt;
&lt;br /&gt;
An expression is a series of operators and quantities to be operated on (operands) that returns a result.  This result can be used as the operand of a larger expression or assigned into a variable.  Expressions are used throughout the language: in &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt; statements, loops, function calls, and they can even be statements by themselves.&lt;br /&gt;
&lt;br /&gt;
This last use is interesting.  Just &amp;lt;tt&amp;gt;1;&amp;lt;/tt&amp;gt; is a valid C statement.  Of course, a statement is only interesting if it has side-effects.  Saying &amp;lt;tt&amp;gt;a=1;&amp;lt;/tt&amp;gt; has the side-effect of assigning the value 1 to the variable &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;.  Side-effects are especially important with the logical operations and the tertiary if-then operator.&lt;br /&gt;
&lt;br /&gt;
====Operators====&lt;br /&gt;
&lt;br /&gt;
There are tons of operators in C.  Mathematical, bitwise logical, logical, comparison, and a few others.  Operators have precedence, meaning that some take effect before others.  Parentheses can be used to do things in the order you want.&lt;br /&gt;
&amp;lt;!-- Maybe these should be in order of precedence? --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Mathematical=====&lt;br /&gt;
&lt;br /&gt;
The most familiar operators for most people are &amp;lt;tt&amp;gt;+&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;-&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; (multiplication) and &amp;lt;tt&amp;gt;&amp;amp;divide;&amp;lt;/tt&amp;gt;.  Division uses a slash &amp;lt;tt&amp;gt;/&amp;lt;/tt&amp;gt;, and there's also the remainder operator &amp;lt;tt&amp;gt;%&amp;lt;/tt&amp;gt; for integers.  I think of the unary operators &amp;lt;tt&amp;gt;+&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;-&amp;lt;/tt&amp;gt; (negative) as mathematical as well.&lt;br /&gt;
&lt;br /&gt;
=====Assignment=====&lt;br /&gt;
&lt;br /&gt;
Assignment operators have the side-effect of setting a variable's value.  In addition to the typical &amp;lt;tt&amp;gt;=&amp;lt;/tt&amp;gt;, there are several operators like &amp;lt;tt&amp;gt;+=&amp;lt;/tt&amp;gt; which means, &amp;quot;Add this to the variable.&amp;quot;  The assignment operators are &amp;lt;tt&amp;gt;=, +=, -=, *=, /=, %=, &amp;amp;=, ^=, |=, &amp;lt;&amp;lt;=,&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;gt;&amp;gt;=&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 a += b; // equivalent to a = a + b&lt;br /&gt;
 a -= b; // equivalent to a = a - b&lt;br /&gt;
&lt;br /&gt;
=====Comparison=====&lt;br /&gt;
&lt;br /&gt;
These operators compare two values, returning 1 for true or 0 for false.  The test to see if two values are equal is &amp;lt;tt&amp;gt;(a == b)&amp;lt;/tt&amp;gt; with a double equals sign.  The comparison operators are &amp;lt;tt&amp;gt;==, !=&amp;lt;/tt&amp;gt; (not equal), &amp;lt;tt&amp;gt;&amp;amp;lt;, &amp;amp;gt;,  &amp;amp;lt;=,&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;amp;gt;=&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A common mistake is the use of something like&lt;br /&gt;
&lt;br /&gt;
 if (a = b) { // WRONG!&lt;br /&gt;
&lt;br /&gt;
when it should have been&lt;br /&gt;
&lt;br /&gt;
 if (a == b) {&lt;br /&gt;
&lt;br /&gt;
The former will redefine ''a'' equal to ''b'', and use the new value of ''a'' as the condition for the IF statement; so for any non-zero value of ''b'', this will succeed  (and mess up ''a'' in the meantime).  Watch out for this trap!  It's ''one'' = for telling, ''two'' == for asking.&lt;br /&gt;
&lt;br /&gt;
=====Logical=====&lt;br /&gt;
&lt;br /&gt;
Logical operators combine values that are true or false.  The key concept is that is not 0 is true, and 0 is false.  Each of these operators returns 1 for true.&lt;br /&gt;
&lt;br /&gt;
 a &amp;amp;&amp;amp; b // test if a AND b are true&lt;br /&gt;
 a || b // test if a OR  b are true &lt;br /&gt;
 !a     // test if the negation of a is true&lt;br /&gt;
 a ^ b  // exclusive-OR; (a || b) &amp;amp;&amp;amp; !(a &amp;amp;&amp;amp; b)&lt;br /&gt;
&lt;br /&gt;
It is important to realise that '''C''' stops processing an expression as soon as the answer is known for sure -- ''not every sub-expression in a compound expression will necessarily be evaluated''.  The expressions a and b can have side-effects like assigning the values of variables.  Because of the difficulty in debugging such expressions, the use of function calls and operators with side-effects within logical expressions is discouraged.  It is common in [[shell]] scripts to use logical operators as quick-and-dirty if statements.&lt;br /&gt;
&lt;br /&gt;
As an example, if we have an expression such as&lt;br /&gt;
&lt;br /&gt;
 if ((a &amp;amp;&amp;amp; b) || c) {&lt;br /&gt;
&lt;br /&gt;
if ''a'' is false, ''b'' will not be evaluated  (because a &amp;amp;&amp;amp; b cannot possibly be true if ''a'' is false).  But ''c'' will have to be evaluated, because we do not know the result in advance.  If ''a'' is true, ''b'' will be evaluated; and if ''b'' is also true, then ''c'' will ''not'' be evaluated, since we know that the result of the OR operation will be true.&lt;br /&gt;
&lt;br /&gt;
=====Tertiary if-then operator=====&lt;br /&gt;
&lt;br /&gt;
This operator is unique in that it takes three operands.  The form is &amp;lt;tt&amp;gt;(a)?(b):(c)&amp;lt;/tt&amp;gt;.  (Parentheses are recommended because this operator has low precedence.)  The operator evaluates &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;, and if it is true, then it returns &amp;lt;tt&amp;gt;b&amp;lt;/tt&amp;gt;.  Otherwise it returns &amp;lt;tt&amp;gt;c&amp;lt;/tt&amp;gt;.  If there are side-effects, a regular &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt; statement is recommended.&lt;br /&gt;
&lt;br /&gt;
Being an operator, ?: ''does'' return a value.  So&lt;br /&gt;
 d = ((a) ? (b) : (c));&lt;br /&gt;
sets ''d'' = ''b''  (and does not evaluate ''c'')  if ''a'' is true  (i.e.  anything but zero), or ''d'' = ''c''  (and does not evaluate ''b'')  if ''a'' is false  (zero).&lt;br /&gt;
&lt;br /&gt;
=====Bitwise Operators=====&lt;br /&gt;
Bitwise operators, as the name suggests, operate on binary numbers on a bit-by-bit basis.&lt;br /&gt;
&lt;br /&gt;
 a &amp;amp; b = bitwise AND&lt;br /&gt;
 a | b = bitwise OR&lt;br /&gt;
 a ^ c = bitwise XOR (exclusive OR)&lt;br /&gt;
&lt;br /&gt;
Each bit of ''a'' is ANDed, ORred or XORred  with the corresponding bit of ''b'' and the answer is inserted in the corresponding bit position in the result.  For example,  ''(I'm using hexadecimal numbers here to make it a little more obvious -- but this obviously works with any numeric values)''&lt;br /&gt;
&lt;br /&gt;
 0xe8 &amp;amp; 0x1f = 0x08&lt;br /&gt;
 0x51 | 0x60 = 0x71&lt;br /&gt;
 0xaa ^ 0xff = 0x55&lt;br /&gt;
&lt;br /&gt;
These operators are very useful when storing several boolean values in an integer or char.  Also, you can somtimes make use of the fact that -- in ASCII codes -- bit 5 (i.e.  the 32's) is ''set'' (1) in the lower case letters, but ''cleared'' (0) in the corresponding capital letter.&lt;br /&gt;
&lt;br /&gt;
=====Bit Shift Operators=====&lt;br /&gt;
These operators shift the bits of a binary number to the left or the right.  Bits that &amp;quot;fall off the end&amp;quot; are lost for all time, and zeros are shifted into the opposite end.&lt;br /&gt;
&lt;br /&gt;
 x = a &amp;lt;&amp;lt; b; // bits of a, left hand shifted b times&lt;br /&gt;
 y = a &amp;gt;&amp;gt; b; // bits of a, right hand shifted b times&lt;br /&gt;
&lt;br /&gt;
These operators are meant to be combined with the bitwise operators above.  Suppose we wished to store a day of the week ''day''  (between 0 and 6), a date within the month ''date''  (between 1 and 31), and a month ''month''  (between 1 and 12)  in an ''int'' variable ''ddm''.  We need 3 bits to store ''day'', 5 bits to store ''date'' and 4 bits to store ''month'', and we could build up an expression like this:&lt;br /&gt;
&lt;br /&gt;
 ddm = (day &amp;lt;&amp;lt; 9) | (date &amp;lt;&amp;lt; 4) | month;&lt;br /&gt;
&lt;br /&gt;
and then the reverse would be&lt;br /&gt;
&lt;br /&gt;
 day = ((ddm &amp;amp; 7&amp;lt;&amp;lt;9) &amp;gt;&amp;gt;9);&lt;br /&gt;
 date = ((ddm &amp;amp; 31&amp;lt;&amp;lt;4) &amp;gt;&amp;gt;4);&lt;br /&gt;
 month = (ddm &amp;amp; 15);&lt;br /&gt;
&lt;br /&gt;
We use the AND operator to select just the bits we are interested in, the two shift operators to position them where we want, and the OR operator to assemble the groups of bits together.&lt;br /&gt;
&lt;br /&gt;
=====Increment and Decrement=====&lt;br /&gt;
The '''++''' and '''--''' operators -- a shorthand notation for adding and subtracting one from a variable -- can each be used in two different ways.  If the operator comes ''after'' the variable name, then the variable is incremented or decremented ''after'' its value is read and passed on.  If the operator comes ''before'' the variable name, then the variable is modified ''before'' its value is read.&lt;br /&gt;
&lt;br /&gt;
 a = b++; // equivalent to a = b; b += 1&lt;br /&gt;
 a = b--; // equivalent to a = b; b -= 1&lt;br /&gt;
 a = ++b; // equivalent to b += 1; a = b&lt;br /&gt;
 a = --b; // equivalent to b -= 1; a = b&lt;br /&gt;
&lt;br /&gt;
=====Other=====&lt;br /&gt;
&lt;br /&gt;
The comma, pointer/structure/array operators, type casts.&lt;br /&gt;
&lt;br /&gt;
===Control structures===&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
====Instruction chunks====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
====''if (else)'' instruction====&lt;br /&gt;
The general look of a C if-then-else statement is something like&amp;lt;br&amp;gt;&lt;br /&gt;
 if(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
    &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt;&lt;br /&gt;
 } else {&lt;br /&gt;
    &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
If &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is different from 0 then &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; (whatever that might be) is executed, otherwise, that is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is 0, &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is executed. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The real issue here is of course; what is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;, &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;. &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is from the compilers point of view any value that can be interpreted as a number, that's almost anything in C. For instance the value 2 would be syntactically correct. The key issue is that 2 is different from 0, thus &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; would be executed. &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is any piece of code actually, for example &amp;lt;tt&amp;gt;printf(&amp;quot;Hello World!&amp;quot;);&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here's an example of an if statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 if(customers &amp;gt; 0){&lt;br /&gt;
     printf(&amp;quot;There are people in the shop&amp;quot;); // state the obvious &lt;br /&gt;
     getHelp(); // call some functions that gets more personnel&lt;br /&gt;
 } else {&lt;br /&gt;
     drinkMoreCoffee(); // do what you're trained to do&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The tertiary operator (above) can be used as a quick form of the if statement.&lt;br /&gt;
&lt;br /&gt;
====''while (do)'' instruction====&lt;br /&gt;
The general look of while statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
     do something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is the same thing as with if statements, i.e. something that can be evaluated either true (different from zero) or false (that is zero). What's happening here is that we first test if &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true, if so the body of the while statement is executed as long as &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true. For example:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 5){&lt;br /&gt;
     a++; &lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, a); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
This would produce the output:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1, 2, 3, 4, 5,&lt;br /&gt;
&lt;br /&gt;
Key note is that weather a is less than 5 or not is just tested in the beginning of the while loop, so it's possible to write the number 5. Then of course the loop is terminated. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The brother while loop is the so called do-while-loop&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 do {&lt;br /&gt;
     do something &lt;br /&gt;
 } while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;); &lt;br /&gt;
&lt;br /&gt;
The key note here is that weather &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true or not is tested at the end of the loop, that means that the body of the loop is executed at least once. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It's of cource possible to construct a loop that runs forever. For example: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 3){&lt;br /&gt;
    printf(&amp;quot;I'm a fruitcake\n&amp;quot;); &lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
====''for'' instruction====&lt;br /&gt;
The general look of a for-loop is:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(A,B,C){&lt;br /&gt;
     fo something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here A is executed just once when we enter the for-loop, typically to initialize some variables. B is a truth conditional like the ones in the while loop, if B is true then we continue looping. C is executed every time at the end of the loop. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(i = 0; i &amp;lt; 5; i++){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
This would produce the output: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 0, 1, 2, 3, 4,&lt;br /&gt;
&lt;br /&gt;
to guide you through it: First i is set to 0, this happens just once. Then we test if i is less than 5, clearly, it's 0. Now we enter the for-loop and print the value of, i. At the end of the loop i is incremented by 1. Then test again weather i is less than 5, print it's values, and so on. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Please note that A, B and C can all be omitted, This is valid syntax: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(;;){&lt;br /&gt;
     printf(&amp;quot;I'm looping forever and I'm happy with it.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It's not too common to introduce loops like this, but it works. The idea is that you can do something like: &lt;br /&gt;
&lt;br /&gt;
 int i = 0; &lt;br /&gt;
 for(;i &amp;lt; 10; printf(&amp;quot;Hello&amp;quot;)){&lt;br /&gt;
     i++; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Also you can do more things in A and C, For example you want to initialize variables i to 0 and j to 5 at the beginning of the loop. &lt;br /&gt;
&lt;br /&gt;
 for(i = 1, j = 5; (i*j) &amp;gt; 0; j++, j--){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i*j); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The , between i = 0 and j = 5 is the separator here. Same style goes at the end where j is incremented and j decremented. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Functions===&lt;br /&gt;
&lt;br /&gt;
Fisrt of all a function can be thought of as a way to store a procedure. This procedure contains some instructions that you want to carry out many times. Also it's a way to structure your program. It can also be regarded as a function in a more mathematical sense. Here is the general outfit of a C function: &lt;br /&gt;
&lt;br /&gt;
 return_type function_name(argument_1, argeument_2, ..., argument_n){&lt;br /&gt;
     function_body&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
A simple example of a function: &lt;br /&gt;
&lt;br /&gt;
 int max_i(int a, int b){&lt;br /&gt;
     if(a &amp;gt; b){&lt;br /&gt;
         return a;&lt;br /&gt;
     }&lt;br /&gt;
     return b; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can of course call other functions, for example: &lt;br /&gt;
&lt;br /&gt;
 int find_max(int *nums, int len){&lt;br /&gt;
     int max = 0, i; &lt;br /&gt;
     for(i = 0; i &amp;lt; len; i++){&lt;br /&gt;
         max = max_i(nums[i], max); &lt;br /&gt;
     }&lt;br /&gt;
     return max; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Further functions can call themselves, this example calculates n!. &lt;br /&gt;
&lt;br /&gt;
 int fac(int n){&lt;br /&gt;
     if(n == 1){&lt;br /&gt;
         return 1; &lt;br /&gt;
     }&lt;br /&gt;
     return n*fac(n - 1); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can return all basic types such as, int, float, double, char, etc. They can also return pointers to all these. They can return pointers to structs and void. If a function is declared to return void it simply returns nothing. Don't confuse this with functions that returns pointers to void, that is void*. returning void* is simply returning a general pointer to something we don't the type of. &lt;br /&gt;
&lt;br /&gt;
An example of a function that 'returns' void. &lt;br /&gt;
&lt;br /&gt;
 void printObvious(){&lt;br /&gt;
     pritnf(&amp;quot;I'm a function that returns nothing.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
As we can see we can omitt the return statement since this function do not return anything. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Further Reading== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===Wiki pages=== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Books==&lt;br /&gt;
*''C Programming Language'', Brian W. Kernighan, [[Dennis Ritchie]]&lt;br /&gt;
*''C: A Reference Manual'', Samuel P. Harbison, Guy L. Steele&lt;br /&gt;
&lt;br /&gt;
==Tutorial Material==&lt;br /&gt;
Since this page serves as something of lanaguage overview more lengthy examples would fit better on it's own page. Check out [[CProgrammingExamples]] for some examples, that might help you getting started with C programming. &lt;br /&gt;
&lt;br /&gt;
''This article is a [[LinuxQuestions.org_Wiki:stub_articles|stub]] and needs to be finished. [[LinuxQuestions.org_Wiki:plunging_forward|Plunge forward]] and [[LinuxQuestions.org_Wiki:How_to_edit_a_page|help it grow]] !''&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=PHP_tips&amp;diff=8375</id>
		<title>PHP tips</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=PHP_tips&amp;diff=8375"/>
		<updated>2004-03-23T22:22:08Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: added hit counter&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==PHP TIPS==&lt;br /&gt;
[[PHP]] Hypertext Preprocessor is a great tool for making dynamic websites. Outside this Wiki, countless tips can be found in the comments section of the [http://www.php.net/manual/en/ official php manual] in the reference pages for each function. Here's a few little PHP tips and tricks.&lt;br /&gt;
&lt;br /&gt;
=== Making your first cut'n paste script work ===&lt;br /&gt;
The first thing people usually do when the experiment with php, is that they get a piece of php script from the web and try to use it. So here's how to make that first piece of code to work:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Change the [[file permissions]] so that your [[webserver]] can use it.&lt;br /&gt;
* Make sure that the php-code starts with ''&amp;lt;?php'', because sometimes just the basic ''&amp;lt;?'' doesn't work (or at least in my configuration)&lt;br /&gt;
* Make sure that the file extension is .php, not .php3, .php4 or .phtml. A lot of these old filenames won't work with modern [[apache]] web servers.&lt;br /&gt;
&lt;br /&gt;
=== Creating larger pages with $variables ===&lt;br /&gt;
The first few pages work well by just by putting the code where you needed in the HTML-page. However,when your scripts grow bigger, it gets messy when you mix php and html.&lt;br /&gt;
I my opinion, the easiest way is to put the PHP-code code at the beginning of the file and the HTML in the end. &lt;br /&gt;
&lt;br /&gt;
The data that your great script has generated should be placed in string-type variables. For example: ''$pagetop'', ''$list'', ''$pageend'' and ''$menu''. &lt;br /&gt;
So now you can put all the generated data to those variables and use them in the HTML-part of you file by just putting ''&amp;lt;?php echo $pagetop; ?&amp;gt;'' in the according place.&lt;br /&gt;
&lt;br /&gt;
By doing this you can easily edit the PHP-scipt and the HTML part of your page without mixing the two so badly that you don't understand anything the next week .&lt;br /&gt;
&lt;br /&gt;
===FANCY TABLES===&lt;br /&gt;
It is easy -- and it also looks really cool 8) -- to generate a table with alternating coloured rows from PHP.  What you have to do is&lt;br /&gt;
#Declare a CSS style class for each background colour.&lt;br /&gt;
#Create an array with the background colours in the order you want them to appear in the table.&lt;br /&gt;
#Place some code in the loop which generates the table, to set a background colour for each row while recirculating the array.&lt;br /&gt;
The following code snippets should make it clear.&lt;br /&gt;
====Defining CSS Classes  (outside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;.DARKBG   {background-color: #bbbbbb}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.MIDDLEBG {background-color: #cccccc}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.LIGHTBG  {background-color: #dddddd}&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Initialising the array  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;$backgrounds = array(&amp;quot;LIGHTBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;, &amp;quot;DARKBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;);&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Building up the table  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;foreach ($foo as $i =&amp;gt; $j) {&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;array_push($backgrounds, ($bg = array_shift($backgrounds));&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;echo &amp;quot;&amp;amp;lt;TR CLASS=\&amp;quot;$bg\&amp;quot;&amp;amp;gt;&amp;quot;;&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;TD&amp;amp;gt;$i&amp;amp;lt;/TD&amp;amp;gt;&amp;amp;lt;TD&amp;amp;gt;$j&amp;amp;lt;/TD&amp;amp;gt;&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;/TR&amp;amp;gt;\n&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;};&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Explanation====&lt;br /&gt;
Each time around the loop  (here I've used a &amp;lt;tt&amp;gt;foreach&amp;lt;/tt&amp;gt; but it could be any kind of loop), the &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; (in the innermost brackets, so it gets evaluated first) causes a variable $bg to be set to the first element in $backgrounds and the others to be shifted down a place.  Then, this is pushed onto the tail end of the shortened array by the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt;.  So the whole array just gets recirculated, each time a value is read from the beginning it is moved to the end.  As the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; functions do not care about the length of the array, you could go through a whole rainbow of colours, or you could just alternate white and coloured rows.&lt;br /&gt;
&lt;br /&gt;
Note that if you want to use more than one table in your page, and you want them all to start on the same colour, you will have to re-create the array between finishing one table and starting the next.  This is because the array actually gets altered each time we go around the loop.&lt;br /&gt;
&lt;br /&gt;
===HIT COUNTER===&lt;br /&gt;
This code can be used to generate a simple hit counter.  It is deliberately kept as simple as possible, so as to make it easier to customise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&amp;lt;?&lt;br /&gt;
    $filename = &amp;quot;count.dat&amp;quot;;                   # must be different for each page&lt;br /&gt;
    $num_hits = 0;&lt;br /&gt;
    if ($fh = fopen(&amp;quot;$filename&amp;quot;,&amp;quot;r&amp;quot;)) {        # open the file&lt;br /&gt;
        $data = fscanf($fh, &amp;quot;%d&amp;quot;);             # read number from file&lt;br /&gt;
        $num_hits = $data[0];&lt;br /&gt;
        $num_hits++;                           # add one to count&lt;br /&gt;
        fclose($fh);&lt;br /&gt;
        if ($fh = fopen(&amp;quot;$filename&amp;quot;,&amp;quot;w&amp;quot;)) {    # write updated value&lt;br /&gt;
            fwrite($fh, &amp;quot;$num_hits\n&amp;quot;);        # back to file&lt;br /&gt;
            fclose($fh);&lt;br /&gt;
        };&lt;br /&gt;
    };&lt;br /&gt;
    echo &amp;quot;$num_hits&amp;quot;;                          # display count&lt;br /&gt;
?&amp;gt;&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Explanation====&lt;br /&gt;
The file specified in &amp;lt;TT&amp;gt;$filename&amp;lt;/TT&amp;gt; must exist and must have permissions 666; it holds the counter value.  Start with just &amp;quot;1&amp;quot; on a line by itself.&lt;br /&gt;
&lt;br /&gt;
The file is opened for reading, and a decimal integer value is read using the &amp;lt;tt&amp;gt;fscanf&amp;lt;/tt&amp;gt; function.  It is then incremented and written back to the file. before being &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt;ed to the screen. &lt;br /&gt;
&lt;br /&gt;
The script '''only''' produces a number.  You probably will want to declare a CSS class for the counter, and surround the PHP block with &amp;amp;lt;SPAN&amp;amp;gt; ... &amp;amp;lt;/SPAN&amp;amp;gt; tags.&lt;br /&gt;
&lt;br /&gt;
To repeat the count elsewhere on the page, use&lt;br /&gt;
&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&amp;lt;?&lt;br /&gt;
    echo &amp;quot;$num_hits&amp;quot;;&lt;br /&gt;
?&amp;gt;&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configuration Tricks and Traps===&lt;br /&gt;
&lt;br /&gt;
Here are some common pitfalls or trickies. Also, go take a look at [http://wact.sourceforge.net/index.php/PhpApplicationSecurity this] for a more comprehensive look at security issues in PHP.&lt;br /&gt;
&lt;br /&gt;
====The &amp;lt;tt&amp;gt;register_globals&amp;lt;/tt&amp;gt; flag (a php.ini config option)====&lt;br /&gt;
&lt;br /&gt;
If set to true, all GET, POST, FILE, and COOKIE variables will be registered as global variables. That is, if you called the url &amp;lt;tt&amp;gt;index.php?page=home&amp;lt;/tt&amp;gt; the script would have the variable &amp;lt;tt&amp;gt;$page&amp;lt;/tt&amp;gt; available, with the value 'home'. However, with register_globals off (the way it should really be, for security) &amp;lt;tt&amp;gt;$page&amp;lt;/tt&amp;gt; would not be available. Instead, you would use &amp;lt;tt&amp;gt;$_GET['page']&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;$HTTP_GET_VARS['page']&amp;lt;/tt&amp;gt; (the first for any version of php beyond about 4.1; the second for older versions).&lt;br /&gt;
&lt;br /&gt;
====The &amp;lt;tt&amp;gt;allow_short_open_tags&amp;lt;/tt&amp;gt; option====&lt;br /&gt;
&lt;br /&gt;
If set to true, &amp;lt;tt&amp;gt;&amp;lt;?&amp;lt;/tt&amp;gt; is a legitimate way of starting a php block. This also means that you can use the short echo syntax: &amp;lt;tt&amp;gt;&amp;lt;?=$var ?&amp;gt;&amp;lt;/tt&amp;gt; will output the value of $var.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the shorts tags are a bad idea if:&lt;br /&gt;
* You are mixing scripting languages. Different languages use different tags, but often use the &amp;lt;? prefix.&lt;br /&gt;
* You have xml content. PHP will choke on the &amp;lt;?xml declaration if you are allowing the short tags; it reads it as a php command &amp;quot;xml&amp;quot;, which of course doesn't work, so spews a parse error.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=User:Ajs318&amp;diff=23439</id>
		<title>User:Ajs318</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=User:Ajs318&amp;diff=23439"/>
		<updated>2004-03-23T16:21:40Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Small-time GNU/Linux user since 1999, when the arrival of a new PC meant I had a spare box to mess about with.  I put Linux on it as a pure experiment, and set it up as a modem sharer.  Then my ISP gave me my very own cgi-bin directory.  Next thing I knew, I was running an apache server, just so I could test my scripts locally before uploading them.&lt;br /&gt;
&lt;br /&gt;
In 2001 I built myself another new PC and was originally planning to dual-boot Windows 98SE with Debian.  Somehow I ended up single-booting Mandrake 8.2, and my life changed for the better after I had seen my last ever blue screen.&lt;br /&gt;
&lt;br /&gt;
Come 2003 I purchased my first &amp;quot;proper&amp;quot; laptop  (i.e.  one capable of running a more sophisticated OS than DOS).&lt;br /&gt;
&lt;br /&gt;
I consider myself something of a hacker, but don't pretend for one instant that I haven't still got a lot to learn.&lt;br /&gt;
&lt;br /&gt;
Obligatory Outrageous Political Statement:  &amp;quot;Closed source software is the electronic equivalent of slavery&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=C&amp;diff=6645</id>
		<title>C</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=C&amp;diff=6645"/>
		<updated>2004-03-23T00:02:27Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''C''' programming language is certainly the most influential in the world of the programming. Created at first by Brian W. Kernighan and Dennis M. Ritchie in 1978, this language is characterized by his closeness to the hardware without being architecture dependent. Not that it is complicated (like Assembly), but you can move generally as you want in the memory for example, but may crash if you are not permitted to read or write to that memory.&lt;br /&gt;
&lt;br /&gt;
The C language is often associated with UNIX, maybe because it has been developed on and written with it. But it is not linked with any system nor architecture. You can use C in many applications with this language. It, however, has come under criticism for being insecure, when it is not used correctly (for example, bounds overflow checking is not done by default - allowing the chance for buffer overflow attacks in poorly written software).&lt;br /&gt;
&lt;br /&gt;
Note that even if it is still the most used, the C language has gradually become an old language. Having been written in 1978 means it was created before many modern studies on programming language theory. These studies provide huge advances in the creation of a language, especially in the precision and speed with which it's compiled. For example, you don't have a real range of lines and columns when there is an error or a warning in C; recent languages do.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==History==&lt;br /&gt;
''(Feed me)''&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Language Features==&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
====Basic Types====&lt;br /&gt;
'''int''': integer&amp;lt;br/&amp;gt;&lt;br /&gt;
'''char''': character&amp;lt;br/&amp;gt;&lt;br /&gt;
'''float''': float&amp;lt;br/&amp;gt;&lt;br /&gt;
'''double''': double float&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''short''': shorter type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''long''': longer type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''signed''': signed type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''unsigned''': unsigned type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===Array and pointers===&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===Structures===&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===User-defined Types=== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--====Constants====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Expressions===&lt;br /&gt;
&lt;br /&gt;
An expression is a series of operators and quantities to be operated on (operands) that returns a result.  This result can be used as the operand of a larger expression or assigned into a variable.  Expressions are used throughout the language: in &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt; statements, loops, function calls, and they can even be statements by themselves.&lt;br /&gt;
&lt;br /&gt;
This last use is interesting.  Just &amp;lt;tt&amp;gt;1;&amp;lt;/tt&amp;gt; is a valid C statement.  Of course, a statement is only interesting if it has side-effects.  Saying &amp;lt;tt&amp;gt;a=1;&amp;lt;/tt&amp;gt; has the side-effect of assigning the value 1 to the variable &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;.  Side-effects are especially important with the logical operations and the tertiary if-then operator.&lt;br /&gt;
&lt;br /&gt;
====Operators====&lt;br /&gt;
&lt;br /&gt;
There are tons of operators in C.  Mathematical, bitwise logical, logical, comparison, and a few others.  Operators have precedence, meaning that some take effect before others.  Parentheses can be used to do things in the order you want.&lt;br /&gt;
&amp;lt;!-- Maybe these should be in order of precedence? --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Mathematical=====&lt;br /&gt;
&lt;br /&gt;
The most familiar operators for most people are &amp;lt;tt&amp;gt;+&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;-&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; (multiplication) and &amp;lt;tt&amp;gt;&amp;amp;divide;&amp;lt;/tt&amp;gt;.  Division uses a slash &amp;lt;tt&amp;gt;/&amp;lt;/tt&amp;gt;, and there's also the remainder operator &amp;lt;tt&amp;gt;%&amp;lt;/tt&amp;gt; for integers.  I think of the unary operators &amp;lt;tt&amp;gt;+&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;-&amp;lt;/tt&amp;gt; (negative) as mathematical as well.&lt;br /&gt;
&lt;br /&gt;
=====Assignment=====&lt;br /&gt;
&lt;br /&gt;
Assignment operators have the side-effect of setting a variable's value.  In addition to the typical &amp;lt;tt&amp;gt;=&amp;lt;/tt&amp;gt;, there are several operators like &amp;lt;tt&amp;gt;+=&amp;lt;/tt&amp;gt; which means, &amp;quot;Add this to the variable.&amp;quot;  The assignment operators are &amp;lt;tt&amp;gt;=, +=, -=, *=, /=, %=, &amp;amp;=, ^=, |=, &amp;lt;&amp;lt;=,&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;gt;&amp;gt;=&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 a += b; // equivalent to a = a + b&lt;br /&gt;
 a -= b; // equivalent to a = a - b&lt;br /&gt;
&lt;br /&gt;
=====Comparison=====&lt;br /&gt;
&lt;br /&gt;
These operators compare two values, returning 1 for true or 0 for false.  The test to see if two values are equal is &amp;lt;tt&amp;gt;(a == b)&amp;lt;/tt&amp;gt; with a double equals sign.  The comparison operators are &amp;lt;tt&amp;gt;==, !=&amp;lt;/tt&amp;gt; (not equal), &amp;lt;tt&amp;gt;&amp;amp;lt;, &amp;amp;gt;,  &amp;amp;lt;=,&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;amp;gt;=&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A common mistake is the use of something like&lt;br /&gt;
&lt;br /&gt;
 if (a = b) { // WRONG!&lt;br /&gt;
&lt;br /&gt;
when it should have been&lt;br /&gt;
&lt;br /&gt;
 if (a == b) {&lt;br /&gt;
&lt;br /&gt;
The former will redefine ''a'' equal to ''b'', and use the new value of ''a'' as the condition for the IF statement; so for any non-zero value of ''b'', this will succeed  (and mess up ''a'' in the meantime).  Watch out for this trap!  It's ''one'' = for telling, ''two'' == for asking.&lt;br /&gt;
&lt;br /&gt;
=====Logical=====&lt;br /&gt;
&lt;br /&gt;
Logical operators combine values that are true or false.  The key concept is that is not 0 is true, and 0 is false.  Each of these operators returns 1 for true.&lt;br /&gt;
&lt;br /&gt;
 a &amp;amp;&amp;amp; b // test if a AND b are true&lt;br /&gt;
 a || b // test if a OR  b are true &lt;br /&gt;
 !a     // test if the negation of a is true&lt;br /&gt;
 a ^ b  // exclusive-OR; (a || b) &amp;amp;&amp;amp; !(a &amp;amp;&amp;amp; b)&lt;br /&gt;
&lt;br /&gt;
It is important to realise that '''C''' stops processing an expression as soon as the answer is known for sure -- ''not every sub-expression in a compound expression will necessarily be evaluated''.  The expressions a and b can have side-effects like assigning the values of variables.  Because of the difficulty in debugging such expressions, the use of function calls and operators with side-effects within logical expressions is discouraged.  It is common in [[shell]] scripts to use logical operators as quick-and-dirty if statements.&lt;br /&gt;
&lt;br /&gt;
As an example, if we have an expression such as&lt;br /&gt;
&lt;br /&gt;
 if ((a &amp;amp;&amp;amp; b) || c) {&lt;br /&gt;
&lt;br /&gt;
if ''a'' is false, ''b'' will not be evaluated  (because a &amp;amp;&amp;amp; b cannot possibly be true if ''a'' is false).  But ''c'' will have to be evaluated, because we do not know the result in advance.  If ''a'' is true, ''b'' will be evaluated; and if ''b'' is also true, then ''c'' will ''not'' be evaluated, since we know that the result of the OR operation will be true.&lt;br /&gt;
&lt;br /&gt;
=====Tertiary if-then operator=====&lt;br /&gt;
&lt;br /&gt;
This operator is unique in that it takes three operands.  The form is &amp;lt;tt&amp;gt;(a)?(b):(c)&amp;lt;/tt&amp;gt;.  (Parentheses are recommended because this operator has low precedence.)  The operator evaluates &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;, and if it is true, then it returns &amp;lt;tt&amp;gt;b&amp;lt;/tt&amp;gt;.  Otherwise it returns &amp;lt;tt&amp;gt;c&amp;lt;/tt&amp;gt;.  If there are side-effects, a regular &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt; statement is recommended.&lt;br /&gt;
&lt;br /&gt;
Being an operator, ?: ''does'' return a value.  So&lt;br /&gt;
 d = ((a) ? (b) : (c));&lt;br /&gt;
sets ''d'' = ''b''  (and does not evaluate ''c'')  if ''a'' is true  (i.e.  anything but zero), or ''d'' = ''c''  (and does not evaluate ''b'')  if ''a'' is false  (zero).&lt;br /&gt;
&lt;br /&gt;
=====Bitwise Operators=====&lt;br /&gt;
Bitwise operators, as the name suggests, operate on binary numbers on a bit-by-bit basis.&lt;br /&gt;
&lt;br /&gt;
 a &amp;amp; b = bitwise AND&lt;br /&gt;
 a | b = bitwise OR&lt;br /&gt;
 a ^ c = bitwise XOR (exclusive OR)&lt;br /&gt;
&lt;br /&gt;
Each bit of ''a'' is ANDed, ORred or XORred  with the corresponding bit of ''b'' and the answer is inserted in the corresponding bit position in the result.  For example,  ''(I'm using hexadecimal numbers here to make it a little more obvious -- but this obviously works with any numeric values)''&lt;br /&gt;
&lt;br /&gt;
 0xe8 &amp;amp; 0x1f = 0x08&lt;br /&gt;
 0x51 | 0x60 = 0x71&lt;br /&gt;
 0xaa ^ 0xff = 0x55&lt;br /&gt;
&lt;br /&gt;
These operators are very useful when storing several boolean values in an integer or char.&lt;br /&gt;
&lt;br /&gt;
=====Bit Shift Operators=====&lt;br /&gt;
These operators shift the bits of a binary number to the left or the right.  Bits that &amp;quot;fall off the end&amp;quot; are lost for all time, and zeros are shifted into the opposite end.&lt;br /&gt;
&lt;br /&gt;
 x = a &amp;lt;&amp;lt; b; // bits of a, left hand shifted b times&lt;br /&gt;
 y = a &amp;gt;&amp;gt; b; // bits of a, right hand shifted b times&lt;br /&gt;
&lt;br /&gt;
These operators are meant to be combined with the bitwise operators above.  Suppose we wished to store a day of the week ''day''  (between 0 and 6), a date within the month ''date''  (between 1 and 31), and a month ''month''  (between 1 and 12)  in an ''int'' variable ''ddm''.  We need 3 bits to store ''day'', 5 bits to store ''date'' and 4 bits to store ''month'', and we could build up an expression like this:&lt;br /&gt;
&lt;br /&gt;
 ddm = (day &amp;lt;&amp;lt; 9) | (date &amp;lt;&amp;lt; 4) | month;&lt;br /&gt;
&lt;br /&gt;
and then the reverse would be&lt;br /&gt;
&lt;br /&gt;
 day = ((ddm &amp;amp; 7&amp;lt;&amp;lt;9) &amp;gt;&amp;gt;9);&lt;br /&gt;
 date = ((ddm &amp;amp; 31&amp;lt;&amp;lt;4) &amp;gt;&amp;gt;4);&lt;br /&gt;
 month = (ddm &amp;amp; 15);&lt;br /&gt;
&lt;br /&gt;
We use the AND operator to select just the bits we are interested in, the two shift operators to position them where we want, and the OR operator to assemble the groups of bits together.&lt;br /&gt;
&lt;br /&gt;
=====Increment and Decrement=====&lt;br /&gt;
The '''++''' and '''--''' operators -- a shorthand notation for adding and subtracting one from a variable -- can each be used in two different ways.  If the operator comes ''after'' the variable name, then the variable is incremented or decremented ''after'' its value is read and passed on.  If the operator comes ''before'' the variable name, then the variable is modified ''before'' its value is read.&lt;br /&gt;
&lt;br /&gt;
 a = b++; // equivalent to a = b; b += 1&lt;br /&gt;
 a = b--; // equivalent to a = b; b -= 1&lt;br /&gt;
 a = ++b; // equivalent to b += 1; a = b&lt;br /&gt;
 a = --b; // equivalent to b -= 1; a = b&lt;br /&gt;
&lt;br /&gt;
=====Other=====&lt;br /&gt;
&lt;br /&gt;
The comma, pointer/structure/array operators, type casts.&lt;br /&gt;
&lt;br /&gt;
===Control structures===&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
====Instruction chunks====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
====''if (else)'' instruction====&lt;br /&gt;
The general look of a C if-then-else statement is something like&amp;lt;br&amp;gt;&lt;br /&gt;
 if(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
    &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt;&lt;br /&gt;
 } else {&lt;br /&gt;
    &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
If &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is different from 0 then &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; (whatever that might be) is executed, otherwise, that is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is 0, &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is executed. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The real issue here is of course; what is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;, &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;. &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is from the compilers point of view any value that can be interpreted as a number, that's almost anything in C. For instance the value 2 would be syntactically correct. The key issue is that 2 is different from 0, thus &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; would be executed. &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is any piece of code actually, for example &amp;lt;tt&amp;gt;printf(&amp;quot;Hello World!&amp;quot;);&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here's an example of an if statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 if(customers &amp;gt; 0){&lt;br /&gt;
     printf(&amp;quot;There are people in the shop&amp;quot;); // state the obvious &lt;br /&gt;
     getHelp(); // call some functions that gets more personnel&lt;br /&gt;
 } else {&lt;br /&gt;
     drinkMoreCoffee(); // do what you're trained to do&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The tertiary operator (above) can be used as a quick form of the if statement.&lt;br /&gt;
&lt;br /&gt;
====''while (do)'' instruction====&lt;br /&gt;
The general look of while statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
     do something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is the same thing as with if statements, i.e. something that can be evaluated either true (different from zero) or false (that is zero). What's happening here is that we first test if &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true, if so the body of the while statement is executed as long as &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true. For example:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 5){&lt;br /&gt;
     a++; &lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, a); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
This would produce the output:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1, 2, 3, 4, 5,&lt;br /&gt;
&lt;br /&gt;
Key note is that weather a is less than 5 or not is just tested in the beginning of the while loop, so it's possible to write the number 5. Then of course the loop is terminated. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The brother while loop is the so called do-while-loop&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 do {&lt;br /&gt;
     do something &lt;br /&gt;
 } while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;); &lt;br /&gt;
&lt;br /&gt;
The key note here is that weather &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true or not is tested at the end of the loop, that means that the body of the loop is executed at least once. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It's of cource possible to construct a loop that runs forever. For example: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 3){&lt;br /&gt;
    printf(&amp;quot;I'm a fruitcake\n&amp;quot;); &lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
====''for'' instruction====&lt;br /&gt;
The general look of a for-loop is:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(A,B,C){&lt;br /&gt;
     fo something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here A is executed just once when we enter the for-loop, typically to initialize some variables. B is a truth conditional like the ones in the while loop, if B is true then we continue looping. C is executed every time at the end of the loop. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(i = 0; i &amp;lt; 5; i++){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
This would produce the output: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 0, 1, 2, 3, 4,&lt;br /&gt;
&lt;br /&gt;
to guide you through it: First i is set to 0, this happens just once. Then we test if i is less than 5, clearly, it's 0. Now we enter the for-loop and print the value of, i. At the end of the loop i is incremented by 1. Then test again weather i is less than 5, print it's values, and so on. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Please note that A, B and C can all be omitted, This is valid syntax: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(;;){&lt;br /&gt;
     printf(&amp;quot;I'm looping forever and I'm happy with it.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It's not too common to introduce loops like this, but it works. The idea is that you can do something like: &lt;br /&gt;
&lt;br /&gt;
 int i = 0; &lt;br /&gt;
 for(;i &amp;lt; 10; printf(&amp;quot;Hello&amp;quot;)){&lt;br /&gt;
     i++; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Also you can do more things in A and C, For example you want to initialize variables i to 0 and j to 5 at the beginning of the loop. &lt;br /&gt;
&lt;br /&gt;
 for(i = 1, j = 5; (i*j) &amp;gt; 0; j++, j--){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i*j); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The , between i = 0 and j = 5 is the separator here. Same style goes at the end where j is incremented and j decremented. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Functions===&lt;br /&gt;
&lt;br /&gt;
Fisrt of all a function can be thought of as a way to store a procedure. This procedure contains some instructions that you want to carry out many times. Also it's a way to structure your program. It can also be regarded as a function in a more mathematical sense. Here is the general outfit of a C function: &lt;br /&gt;
&lt;br /&gt;
 return_type function_name(argument_1, argeument_2, ..., argument_n){&lt;br /&gt;
     function_body&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
A simple example of a function: &lt;br /&gt;
&lt;br /&gt;
 int max_i(int a, int b){&lt;br /&gt;
     if(a &amp;gt; b){&lt;br /&gt;
         return a;&lt;br /&gt;
     }&lt;br /&gt;
     return b; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can of course call other functions, for example: &lt;br /&gt;
&lt;br /&gt;
 int find_max(int *nums, int len){&lt;br /&gt;
     int max = 0, i; &lt;br /&gt;
     for(i = 0; i &amp;lt; len; i++){&lt;br /&gt;
         max = max_i(nums[i], max); &lt;br /&gt;
     }&lt;br /&gt;
     return max; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Further functions can call themselves, this example calculates n!. &lt;br /&gt;
&lt;br /&gt;
 int fac(int n){&lt;br /&gt;
     if(n == 1){&lt;br /&gt;
         return 1; &lt;br /&gt;
     }&lt;br /&gt;
     return n*fac(n - 1); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can return all basic types such as, int, float, double, char, etc. They can also return pointers to all these. They can return pointers to structs and void. If a function is declared to return void it simply returns nothing. Don't confuse this with functions that returns pointers to void, that is void*. returning void* is simply returning a general pointer to something we don't the type of. &lt;br /&gt;
&lt;br /&gt;
An example of a function that 'returns' void. &lt;br /&gt;
&lt;br /&gt;
 void printObvious(){&lt;br /&gt;
     pritnf(&amp;quot;I'm a function that returns nothing.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
As we can see we can omitt the return statement since this function do not return anything. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Further Reading== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===Wiki pages=== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Books==&lt;br /&gt;
*''C Programming Language'', Brian W. Kernighan, [[Dennis Ritchie]]&lt;br /&gt;
*''C: A Reference Manual'', Samuel P. Harbison, Guy L. Steele&lt;br /&gt;
&lt;br /&gt;
==Tutorial Material==&lt;br /&gt;
Since this page serves as something of lanaguage overview more lengthy examples would fit better on it's own page. Check out [[CProgrammingExamples]] for some examples, that might help you getting started with C programming. &lt;br /&gt;
&lt;br /&gt;
''This article is a [[LinuxQuestions.org_Wiki:stub_articles|stub]] and needs to be finished. [[LinuxQuestions.org_Wiki:plunging_forward|Plunge forward]] and [[LinuxQuestions.org_Wiki:How_to_edit_a_page|help it grow]] !''&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=C&amp;diff=5965</id>
		<title>C</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=C&amp;diff=5965"/>
		<updated>2004-03-22T23:53:14Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: added bitwise, bit shift and increment/decrement&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''C''' programming language is certainly the most influential in the world of the programming. Created at first by Brian W. Kernighan and Dennis M. Ritchie in 1978, this language is characterized by his closeness to the hardware without being architecture dependent. Not that it is complicated (like Assembly), but you can move generally as you want in the memory for example, but may crash if you are not permitted to read or write to that memory.&lt;br /&gt;
&lt;br /&gt;
The C language is often associated with UNIX, maybe because it has been developed on and written with it. But it is not linked with any system nor architecture. You can use C in many applications with this language. It, however, has come under criticism for being insecure, when it is not used correctly (for example, bounds overflow checking is not done by default - allowing the chance for buffer overflow attacks in poorly written software).&lt;br /&gt;
&lt;br /&gt;
Note that even if it is still the most used, the C language has gradually become an old language. Having been written in 1978 means it was created before many modern studies on programming language theory. These studies provide huge advances in the creation of a language, especially in the precision and speed with which it's compiled. For example, you don't have a real range of lines and columns when there is an error or a warning in C; recent languages do.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==History==&lt;br /&gt;
''(Feed me)''&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Language Features==&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
====Basic Types====&lt;br /&gt;
'''int''': integer&amp;lt;br/&amp;gt;&lt;br /&gt;
'''char''': character&amp;lt;br/&amp;gt;&lt;br /&gt;
'''float''': float&amp;lt;br/&amp;gt;&lt;br /&gt;
'''double''': double float&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''short''': shorter type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''long''': longer type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''signed''': signed type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''unsigned''': unsigned type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===Array and pointers===&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===Structures===&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===User-defined Types=== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--====Constants====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Expressions===&lt;br /&gt;
&lt;br /&gt;
An expression is a series of operators and quantities to be operated on (operands) that returns a result.  This result can be used as the operand of a larger expression or assigned into a variable.  Expressions are used throughout the language: in &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt; statements, loops, function calls, and they can even be statements by themselves.&lt;br /&gt;
&lt;br /&gt;
This last use is interesting.  Just &amp;lt;tt&amp;gt;1;&amp;lt;/tt&amp;gt; is a valid C statement.  Of course, a statement is only interesting if it has side-effects.  Saying &amp;lt;tt&amp;gt;a=1;&amp;lt;/tt&amp;gt; has the side-effect of assigning the value 1 to the variable &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;.  Side-effects are especially important with the logical operations and the tertiary if-then operator.&lt;br /&gt;
&lt;br /&gt;
====Operators====&lt;br /&gt;
&lt;br /&gt;
There are tons of operators in C.  Mathematical, bitwise logical, logical, comparison, and a few others.  Operators have precedence, meaning that some take effect before others.  Parentheses can be used to do things in the order you want.&lt;br /&gt;
&amp;lt;!-- Maybe these should be in order of precedence? --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Mathematical=====&lt;br /&gt;
&lt;br /&gt;
The most familiar operators for most people are &amp;lt;tt&amp;gt;+&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;-&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; (multiplication) and &amp;lt;tt&amp;gt;&amp;amp;divide;&amp;lt;/tt&amp;gt;.  Division uses a slash &amp;lt;tt&amp;gt;/&amp;lt;/tt&amp;gt;, and there's also the remainder operator &amp;lt;tt&amp;gt;%&amp;lt;/tt&amp;gt; for integers.  I think of the unary operators &amp;lt;tt&amp;gt;+&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;-&amp;lt;/tt&amp;gt; (negative) as mathematical as well.&lt;br /&gt;
&lt;br /&gt;
=====Assignment=====&lt;br /&gt;
&lt;br /&gt;
Assignment operators have the side-effect of setting a variable's value.  In addition to the typical &amp;lt;tt&amp;gt;=&amp;lt;/tt&amp;gt;, there are several operators like &amp;lt;tt&amp;gt;+=&amp;lt;/tt&amp;gt; which means, &amp;quot;Add this to the variable.&amp;quot;  The assignment operators are &amp;lt;tt&amp;gt;=, +=, -=, *=, /=, %=, &amp;amp;=, ^=, |=, &amp;lt;&amp;lt;=,&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;gt;&amp;gt;=&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 a += b; // equivalent to a = a + b&lt;br /&gt;
 a -= b; // equivalent to a = a - b&lt;br /&gt;
&lt;br /&gt;
=====Comparison=====&lt;br /&gt;
&lt;br /&gt;
These operators compare two values, returning 1 for true or 0 for false.  The test to see if two values are equal is &amp;lt;tt&amp;gt;(a == b)&amp;lt;/tt&amp;gt; with a double equals sign.  The comparison operators are &amp;lt;tt&amp;gt;==, !=&amp;lt;/tt&amp;gt; (not equal), &amp;lt;tt&amp;gt;&amp;amp;lt;, &amp;amp;gt;,  &amp;amp;lt;=,&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;amp;gt;=&amp;lt;/tt&amp;gt;.&lt;br /&gt;
=====Logical=====&lt;br /&gt;
&lt;br /&gt;
Logical operators combine values that are true or false.  The key concept is that is not 0 is true, and 0 is false.  Each of these operators returns 1 for true.&lt;br /&gt;
&lt;br /&gt;
 a &amp;amp;&amp;amp; b // test if a AND b are true&lt;br /&gt;
 a || b // test if a OR  b are true &lt;br /&gt;
 !a     // test if the negation of a is true&lt;br /&gt;
 a ^ b  // exclusive-OR; (a || b) &amp;amp;&amp;amp; !(a &amp;amp;&amp;amp; b)&lt;br /&gt;
&lt;br /&gt;
It is important to realise that '''C''' stops processing an expression as soon as the answer is known for sure -- ''not every sub-expression in a compound expression will necessarily be evaluated''.  The expressions a and b can have side-effects like assigning the values of variables.  Because of the difficulty in debugging such expressions, the use of function calls and operators with side-effects within logical expressions is discouraged.  It is common in [[shell]] scripts to use logical operators as quick-and-dirty if statements.&lt;br /&gt;
&lt;br /&gt;
As an example, if we have an expression such as&lt;br /&gt;
&lt;br /&gt;
 if ((a &amp;amp;&amp;amp; b) || c) {&lt;br /&gt;
&lt;br /&gt;
if ''a'' is false, ''b'' will not be evaluated  (because a &amp;amp;&amp;amp; b cannot possibly be true if ''a'' is false).  But ''c'' will have to be evaluated, because we do not know the result in advance.  If ''a'' is true, ''b'' will be evaluated; and if ''b'' is also true, then ''c'' will ''not'' be evaluated, since we know that the result of the OR operation will be true.&lt;br /&gt;
&lt;br /&gt;
=====Tertiary if-then operator=====&lt;br /&gt;
&lt;br /&gt;
This operator is unique in that it takes three operands.  The form is &amp;lt;tt&amp;gt;(a)?(b):(c)&amp;lt;/tt&amp;gt;.  (Parentheses are recommended because this operator has low precedence.)  The operator evaluates &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;, and if it is true, then it returns &amp;lt;tt&amp;gt;b&amp;lt;/tt&amp;gt;.  Otherwise it returns &amp;lt;tt&amp;gt;c&amp;lt;/tt&amp;gt;.  If there are side-effects, a regular &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt; statement is recommended.&lt;br /&gt;
&lt;br /&gt;
Being an operator, ?: ''does'' return a value.  So&lt;br /&gt;
 d = ((a) ? (b) : (c));&lt;br /&gt;
sets d = b  (and does not evaluate c)  if a is true  (i.e.  anything but zero), or d = c  (and does not evaluate b)  if a is false  (zero).&lt;br /&gt;
&lt;br /&gt;
=====Bitwise Operators=====&lt;br /&gt;
Bitwise operators, as the name suggests, operate on binary numbers on a bit-by-bit basis.&lt;br /&gt;
&lt;br /&gt;
 a &amp;amp; b = bitwise AND&lt;br /&gt;
 a | b = bitwise OR&lt;br /&gt;
 a ^ c = bitwise XOR (exclusive OR)&lt;br /&gt;
&lt;br /&gt;
Each bit of ''a'' is ANDed, ORred or XORred  with the corresponding bit of ''b'' and the answer is inserted in the corresponding bit position in the result.  For example,  ''(I'm using hexadecimal numbers here to make it a little more obvious -- but this obviously works with any numeric values)''&lt;br /&gt;
&lt;br /&gt;
 0xe8 &amp;amp; 0x1f = 0x08&lt;br /&gt;
 0x51 | 0x60 = 0x71&lt;br /&gt;
 0xaa ^ 0xff = 0x55&lt;br /&gt;
&lt;br /&gt;
These operators are very useful when storing several boolean values in an integer or char.&lt;br /&gt;
&lt;br /&gt;
=====Bit Shift Operators=====&lt;br /&gt;
These operators shift the bits of a binary number to the left or the right.  Bits that &amp;quot;fall off the end&amp;quot; are lost for all time, and zeros are shifted into the opposite end.&lt;br /&gt;
&lt;br /&gt;
 x = a &amp;lt;&amp;lt; b; // bits of a, left hand shifted b times&lt;br /&gt;
 y = a &amp;gt;&amp;gt; b; // bits of a, right hand shifted b times&lt;br /&gt;
&lt;br /&gt;
These operators are meant to be combined with the bitwise operators above.  Suppose we wished to store a day of the week ''day''  (between 0 and 6), a date within the month ''date''  (between 1 and 31), and a month ''month''  (between 1 and 12)  in an ''int'' variable ''ddm''.  We need 3 bits to store ''day'', 5 bits to store ''date'' and 4 bits to store ''month'', and we could build up an expression like this:&lt;br /&gt;
&lt;br /&gt;
 ddm = (day &amp;lt;&amp;lt; 9) | (date &amp;lt;&amp;lt; 4) | month;&lt;br /&gt;
&lt;br /&gt;
and then the reverse would be&lt;br /&gt;
&lt;br /&gt;
 day = ((ddm &amp;amp; 7&amp;lt;&amp;lt;9) &amp;gt;&amp;gt;9);&lt;br /&gt;
 date = ((ddm &amp;amp; 31&amp;lt;&amp;lt;4) &amp;gt;&amp;gt;4);&lt;br /&gt;
 month = (ddm &amp;amp; 15);&lt;br /&gt;
&lt;br /&gt;
We use the AND operator to select just the bits we are interested in, the two shift operators to position them where we want, and the OR operator to assemble the groups of bits together.&lt;br /&gt;
&lt;br /&gt;
=====Increment and Decrement=====&lt;br /&gt;
The '''++''' and '''--''' operators -- a shorthand notation for adding and subtracting one from a variable -- can each be used in two different ways.  If the operator comes ''after'' the variable name, then the variable is incremented or decremented ''after'' its value is read and passed on.  If the operator comes ''before'' the variable name, then the variable is modified ''before'' its value is read.&lt;br /&gt;
&lt;br /&gt;
 a = b++; // equivalent to a = b; b += 1&lt;br /&gt;
 a = b--; // equivalent to a = b; b -= 1&lt;br /&gt;
 a = ++b; // equivalent to b += 1; a = b&lt;br /&gt;
 a = --b; // equivalent to b -= 1; a = b&lt;br /&gt;
&lt;br /&gt;
=====Other=====&lt;br /&gt;
&lt;br /&gt;
The comma, pointer/structure/array operators, type casts.&lt;br /&gt;
&lt;br /&gt;
===Control structures===&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
====Instruction chunks====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
====''if (else)'' instruction====&lt;br /&gt;
The general look of a C if-then-else statement is something like&amp;lt;br&amp;gt;&lt;br /&gt;
 if(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
    &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt;&lt;br /&gt;
 } else {&lt;br /&gt;
    &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
If &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is different from 0 then &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; (whatever that might be) is executed, otherwise, that is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is 0, &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is executed. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The real issue here is of course; what is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;, &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;. &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is from the compilers point of view any value that can be interpreted as a number, that's almost anything in C. For instance the value 2 would be syntactically correct. The key issue is that 2 is different from 0, thus &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; would be executed. &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is any piece of code actually, for example &amp;lt;tt&amp;gt;printf(&amp;quot;Hello World!&amp;quot;);&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here's an example of an if statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 if(customers &amp;gt; 0){&lt;br /&gt;
     printf(&amp;quot;There are people in the shop&amp;quot;); // state the obvious &lt;br /&gt;
     getHelp(); // call some functions that gets more personnel&lt;br /&gt;
 } else {&lt;br /&gt;
     drinkMoreCoffee(); // do what you're trained to do&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The tertiary operator (above) can be used as a quick form of the if statement.&lt;br /&gt;
&lt;br /&gt;
====''while (do)'' instruction====&lt;br /&gt;
The general look of while statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
     do something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is the same thing as with if statements, i.e. something that can be evaluated either true (different from zero) or false (that is zero). What's happening here is that we first test if &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true, if so the body of the while statement is executed as long as &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true. For example:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 5){&lt;br /&gt;
     a++; &lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, a); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
This would produce the output:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1, 2, 3, 4, 5,&lt;br /&gt;
&lt;br /&gt;
Key note is that weather a is less than 5 or not is just tested in the beginning of the while loop, so it's possible to write the number 5. Then of course the loop is terminated. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The brother while loop is the so called do-while-loop&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 do {&lt;br /&gt;
     do something &lt;br /&gt;
 } while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;); &lt;br /&gt;
&lt;br /&gt;
The key note here is that weather &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true or not is tested at the end of the loop, that means that the body of the loop is executed at least once. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It's of cource possible to construct a loop that runs forever. For example: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 3){&lt;br /&gt;
    printf(&amp;quot;I'm a fruitcake\n&amp;quot;); &lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
====''for'' instruction====&lt;br /&gt;
The general look of a for-loop is:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(A,B,C){&lt;br /&gt;
     fo something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here A is executed just once when we enter the for-loop, typically to initialize some variables. B is a truth conditional like the ones in the while loop, if B is true then we continue looping. C is executed every time at the end of the loop. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(i = 0; i &amp;lt; 5; i++){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
This would produce the output: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 0, 1, 2, 3, 4,&lt;br /&gt;
&lt;br /&gt;
to guide you through it: First i is set to 0, this happens just once. Then we test if i is less than 5, clearly, it's 0. Now we enter the for-loop and print the value of, i. At the end of the loop i is incremented by 1. Then test again weather i is less than 5, print it's values, and so on. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Please note that A, B and C can all be omitted, This is valid syntax: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(;;){&lt;br /&gt;
     printf(&amp;quot;I'm looping forever and I'm happy with it.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It's not too common to introduce loops like this, but it works. The idea is that you can do something like: &lt;br /&gt;
&lt;br /&gt;
 int i = 0; &lt;br /&gt;
 for(;i &amp;lt; 10; printf(&amp;quot;Hello&amp;quot;)){&lt;br /&gt;
     i++; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Also you can do more things in A and C, For example you want to initialize variables i to 0 and j to 5 at the beginning of the loop. &lt;br /&gt;
&lt;br /&gt;
 for(i = 1, j = 5; (i*j) &amp;gt; 0; j++, j--){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i*j); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The , between i = 0 and j = 5 is the separator here. Same style goes at the end where j is incremented and j decremented. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Functions===&lt;br /&gt;
&lt;br /&gt;
Fisrt of all a function can be thought of as a way to store a procedure. This procedure contains some instructions that you want to carry out many times. Also it's a way to structure your program. It can also be regarded as a function in a more mathematical sense. Here is the general outfit of a C function: &lt;br /&gt;
&lt;br /&gt;
 return_type function_name(argument_1, argeument_2, ..., argument_n){&lt;br /&gt;
     function_body&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
A simple example of a function: &lt;br /&gt;
&lt;br /&gt;
 int max_i(int a, int b){&lt;br /&gt;
     if(a &amp;gt; b){&lt;br /&gt;
         return a;&lt;br /&gt;
     }&lt;br /&gt;
     return b; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can of course call other functions, for example: &lt;br /&gt;
&lt;br /&gt;
 int find_max(int *nums, int len){&lt;br /&gt;
     int max = 0, i; &lt;br /&gt;
     for(i = 0; i &amp;lt; len; i++){&lt;br /&gt;
         max = max_i(nums[i], max); &lt;br /&gt;
     }&lt;br /&gt;
     return max; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Further functions can call themselves, this example calculates n!. &lt;br /&gt;
&lt;br /&gt;
 int fac(int n){&lt;br /&gt;
     if(n == 1){&lt;br /&gt;
         return 1; &lt;br /&gt;
     }&lt;br /&gt;
     return n*fac(n - 1); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can return all basic types such as, int, float, double, char, etc. They can also return pointers to all these. They can return pointers to structs and void. If a function is declared to return void it simply returns nothing. Don't confuse this with functions that returns pointers to void, that is void*. returning void* is simply returning a general pointer to something we don't the type of. &lt;br /&gt;
&lt;br /&gt;
An example of a function that 'returns' void. &lt;br /&gt;
&lt;br /&gt;
 void printObvious(){&lt;br /&gt;
     pritnf(&amp;quot;I'm a function that returns nothing.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
As we can see we can omitt the return statement since this function do not return anything. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Further Reading== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ===Wiki pages=== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Books==&lt;br /&gt;
*''C Programming Language'', Brian W. Kernighan, [[Dennis Ritchie]]&lt;br /&gt;
*''C: A Reference Manual'', Samuel P. Harbison, Guy L. Steele&lt;br /&gt;
&lt;br /&gt;
==Tutorial Material==&lt;br /&gt;
Since this page serves as something of lanaguage overview more lengthy examples would fit better on it's own page. Check out [[CProgrammingExamples]] for some examples, that might help you getting started with C programming. &lt;br /&gt;
&lt;br /&gt;
''This article is a [[LinuxQuestions.org_Wiki:stub_articles|stub]] and needs to be finished. [[LinuxQuestions.org_Wiki:plunging_forward|Plunge forward]] and [[LinuxQuestions.org_Wiki:How_to_edit_a_page|help it grow]] !''&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=C&amp;diff=5659</id>
		<title>C</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=C&amp;diff=5659"/>
		<updated>2004-03-20T23:41:09Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''C''' programming language is certainly the most influential in the world of the programming. Created at first by Brian W. Kernighan and Dennis M. Ritchie in 1978, this language is characterized by his closeness to the hardware without being architecture dependent. Not that it is complicated (like Assembly), but you can move generally as you want in the memory for example, but may crash if you are not permitted to read or write to that memory.&lt;br /&gt;
&lt;br /&gt;
The C language is often associated with UNIX, maybe because it has been developed on and written with it. But it is not linked with any system nor architecture. You can use C in many applications with this language. It, however, has come under criticism for being insecure, when it is not used correctly (for example, bounds overflow checking is not done by default - allowing the chance for buffer overflow attacks in poorly written software).&lt;br /&gt;
&lt;br /&gt;
Note that even if it is still the most used, the C language has gradually become an old language. Having been written in 1978 means it was created before many modern studies on programming language theory. These studies provide huge advances in the creation of a language, especially in the precision and speed with which it's compiled. For example, you don't have a real range of lines and columns when there is an error or a warning in C; recent languages do.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
==History==&lt;br /&gt;
''(Feed me)''&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Language Features==&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
====Foundations====&lt;br /&gt;
'''int''': integer&amp;lt;br/&amp;gt;&lt;br /&gt;
'''char''': character&amp;lt;br/&amp;gt;&lt;br /&gt;
'''float''': float&amp;lt;br/&amp;gt;&lt;br /&gt;
'''double''': double float&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''short''': shorter type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''long''': longer type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''signed''': signed type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''unsigned''': unsigned type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
====Constants====&lt;br /&gt;
(Feed me)&lt;br /&gt;
&lt;br /&gt;
====Operators====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
===Control structures===&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
====Instruction chunks====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
====''if (else)'' instruction====&lt;br /&gt;
The general look of a C if-then-else statement is something like&amp;lt;br&amp;gt;&lt;br /&gt;
 if(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
    &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt;&lt;br /&gt;
 } else {&lt;br /&gt;
    &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
If &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is different from 0 then &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; (whatever that might be) is executed, otherwise, that is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is 0, &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is executed. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The real issue here is of course; what is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;, &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;. &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is from the compilers point of view any value that can be interpreted as a number, that's almost anything in C. For instance the value 2 would be syntactically correct. The key issue is that 2 is different from 0, thus &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; would be executed. &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is any piece of code actually, for example &amp;lt;tt&amp;gt;printf(&amp;quot;Hello World!&amp;quot;);&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here are some ideas about what &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; could be: &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Typical cases, testing values: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 a == b // test if a has the same value as b, if so &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; is executed&lt;br /&gt;
 a != b // test if a is different from b, if so &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; is executed&lt;br /&gt;
 a &amp;gt; b  // test if a is greater than b, if so &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt;... (you get the  drift)&lt;br /&gt;
 a &amp;lt; b  // test if a is less than b&lt;br /&gt;
 a &amp;gt;= b // test if a is greater or equal than b&lt;br /&gt;
 a &amp;lt;= b // test if a is less or equal than b&lt;br /&gt;
&lt;br /&gt;
Further you can do logical operations as well. The key concept is that everything different from 0 is true, and 0 is false. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 a &amp;amp;&amp;amp; b // test if a AND b are true, that is different from 0&lt;br /&gt;
 a || b // test if a OR  b are true &lt;br /&gt;
 a ^ b  // exclusive-OR; true if either a or b is true, false if both are true&lt;br /&gt;
 !a     // test if the negation of a is true&lt;br /&gt;
&lt;br /&gt;
Note that a and b can be any expression that returns a value, and may affect the values of variables in the course of generating those values.  It is important to realise that '''C''' stops processing an expression as soon as the answer is known for sure -- ''not every sub-expression in a compound expression will necessarily be evaluated''.  For example, if we have an expression such as&lt;br /&gt;
&lt;br /&gt;
 if ((a &amp;amp;&amp;amp; b) || c) {&lt;br /&gt;
&lt;br /&gt;
if ''a'' is false, ''b'' will not be evaluated  (because a &amp;amp;&amp;amp; b cannot possibly be true if ''a'' is false).  But ''c'' will have to be evaluated, because we do not know the result in advance.  If ''a'' is true, ''b'' will be evaluated; and if ''b'' is also true, then ''c'' will ''not'' be evaluated, since we know that the result of the OR operation will be true.&lt;br /&gt;
&lt;br /&gt;
Here's a more comprehensive example of an if statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 if(customers &amp;gt; 0){&lt;br /&gt;
     printf(&amp;quot;There are people in the shop&amp;quot;); // state the obvious &lt;br /&gt;
     getHelp(); // call some functions that gets more personnel&lt;br /&gt;
 } else {&lt;br /&gt;
     drinkMoreCoffee(); // do what you're trained to do&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==== quick form of ''if'' statement ====&lt;br /&gt;
 if (a) {&lt;br /&gt;
         b&lt;br /&gt;
 } else {&lt;br /&gt;
         c&lt;br /&gt;
 }&lt;br /&gt;
is such a useful construct that there is a shorthand way to write it, which is especially handy when ''a'', ''b'' and ''c'' are all quite short expressions.  This is&lt;br /&gt;
 a ? b : c;&lt;br /&gt;
If ''a'' is true, ''b'' is evaluated; otherwise, ''c'' is evaluated.  Note that (a ? b : c) returns a value  (from ''b'' or ''c'' as appropriate)  and can be assigned to a variable or passed to a function as required.&lt;br /&gt;
&lt;br /&gt;
====''while (do)'' instruction====&lt;br /&gt;
The general look of while statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
     do something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is the same thing as with if statements, i.e. something that can be evaluated either true (different from zero) or false (that is zero). What's happening here is that we first test if &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true, if so the body of the while statement is executed as long as &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true. For example:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 5){&lt;br /&gt;
     a++; &lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, a); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
This would produce the output:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1, 2, 3, 4, 5,&lt;br /&gt;
&lt;br /&gt;
Key note is that weather a is less than 5 or not is just tested in the beginning of the while loop, so it's possible to write the number 5. Then of course the loop is terminated. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The brother while loop is the so called do-while-loop&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 do {&lt;br /&gt;
     do something &lt;br /&gt;
 } while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;); &lt;br /&gt;
&lt;br /&gt;
The key note here is that weather &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true or not is tested at the end of the loop, that means that the body of the loop is executed at least once. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It's of cource possible to construct a loop that runs forever. For example: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 3){&lt;br /&gt;
    printf(&amp;quot;I'm a fruitcake\n&amp;quot;); &lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
====''for'' instruction====&lt;br /&gt;
The general look of a for-loop is:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(A,B,C){&lt;br /&gt;
     fo something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here A is executed just once when we enter the for-loop, typically to initialize some variables. B is a truth conditional like the ones in the while loop, if B is true then we continue looping. C is executed every time at the end of the loop. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(i = 0; i &amp;lt; 5; i++){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
This would produce the output: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 0, 1, 2, 3, 4,&lt;br /&gt;
&lt;br /&gt;
to guide you through it: First i is set to 0, this happens just once. Then we test if i is less than 5, clearly, it's 0. Now we enter the for-loop and print the value of, i. At the end of the loop i is incremented by 1. Then test again weather i is less than 5, print it's values, and so on. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Please note that A, B and C can all be omitted, This is valid syntax: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(;;){&lt;br /&gt;
     printf(&amp;quot;I'm looping forever and I'm happy with it.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It's not too common to introduce loops like this, but it works. The idea is that you can do something like: &lt;br /&gt;
&lt;br /&gt;
 int i = 0; &lt;br /&gt;
 for(;i &amp;lt; 10; printf(&amp;quot;Hello&amp;quot;)){&lt;br /&gt;
     i++; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Also you can do more things in A and C, For example you want to initialize variables i to 0 and j to 5 at the beginning of the loop. &lt;br /&gt;
&lt;br /&gt;
 for(i = 1, j = 5; (i*j) &amp;gt; 0; j++, j--){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i*j); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The , between i = 0 and j = 5 is the separator here. Same style goes at the end where j is incremented and j decremented. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Functions===&lt;br /&gt;
&lt;br /&gt;
Fisrt of all a function can be thought of as a way to store a procedure. This procedure contains some instructions that you want to carry out many times. Also it's a way to structure your program. It can also be regarded as a function in a more mathematical sense. Here is the general outfit of a C function: &lt;br /&gt;
&lt;br /&gt;
 return_type function_name(argument_1, argeument_2, ..., argument_n){&lt;br /&gt;
     function_body&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
A simple example of a function: &lt;br /&gt;
&lt;br /&gt;
 int max_i(int a, int b){&lt;br /&gt;
     if(a &amp;gt; b){&lt;br /&gt;
         return a;&lt;br /&gt;
     }&lt;br /&gt;
     return b; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can of course call other functions, for example: &lt;br /&gt;
&lt;br /&gt;
 int find_max(int *nums, int len){&lt;br /&gt;
     int max = 0, i; &lt;br /&gt;
     for(i = 0; i &amp;lt; len; i++){&lt;br /&gt;
         max = max_i(nums[i], max); &lt;br /&gt;
     }&lt;br /&gt;
     return max; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Further functions can call themselves, this example calculates n!. &lt;br /&gt;
&lt;br /&gt;
 int fac(int n){&lt;br /&gt;
     if(n == 1){&lt;br /&gt;
         return 1; &lt;br /&gt;
     }&lt;br /&gt;
     return n*fac(n - 1); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can return all basic types such as, int, float, double, char, etc. They can also return pointers to all these. They can return pointers to structs and void. If a function is declared to return void it simply returns nothing. Don't confuse this with functions that returns pointers to void, that is void*. returning void* is simply returning a general pointer to something we don't the type of. &lt;br /&gt;
&lt;br /&gt;
An example of a function that 'returns' void. &lt;br /&gt;
&lt;br /&gt;
 void printObvious(){&lt;br /&gt;
     pritnf(&amp;quot;I'm a function that returns nothing.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
As we can see we can omitt the return statement since this function do not return anything. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
===Array and pointers===&lt;br /&gt;
(Feed me)&lt;br /&gt;
&lt;br /&gt;
===Structures===&lt;br /&gt;
(Feed me)&lt;br /&gt;
&lt;br /&gt;
==Further Reading==&lt;br /&gt;
&lt;br /&gt;
===Wiki pages===&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Books==&lt;br /&gt;
*''C Programming Language'', Brian W. Kernighan, [[Dennis Ritchie]]&lt;br /&gt;
*''C: A Reference Manual'', Samuel P. Harbison, Guy L. Steele&lt;br /&gt;
&lt;br /&gt;
==Tutorial Material==&lt;br /&gt;
Since this page serves as something of lanaguage overview more lengthy examples would fit better on it's own page. Check out [[CProgrammingExamples]] for some examples, that might help you getting started with C programming. &lt;br /&gt;
&lt;br /&gt;
''This article is a [[LinuxQuestions.org_Wiki:stub_articles|stub]] and needs to be finished. [[LinuxQuestions.org_Wiki:plunging_forward|Plunge forward]] and [[LinuxQuestions.org_Wiki:How_to_edit_a_page|help it grow]] !''&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=C&amp;diff=5500</id>
		<title>C</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=C&amp;diff=5500"/>
		<updated>2004-03-20T23:39:26Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: added ^ XOR, ?: notation, and fixed a few typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''C''' programming language is certainly the most influential in the world of the programming. Created at first by Brian W. Kernighan and Dennis M. Ritchie in 1978, this language is characterized by his closeness to the hardware without being architecture dependent. Not that it is complicated (like Assembly), but you can move generally as you want in the memory for example, but may crash if you are not permitted to read or write to that memory.&lt;br /&gt;
&lt;br /&gt;
The C language is often associated with UNIX, maybe because it has been developed on and written with it. But it is not linked with any system nor architecture. You can use C in many applications with this language. It, however, has come under criticism for being insecure, when it is not used correctly (for example, bounds overflow checking is not done by default - allowing the chance for buffer overflow attacks in poorly written software).&lt;br /&gt;
&lt;br /&gt;
Note that even if it is still the most used, the C language has gradually become an old language. Having been written in 1978 means it was created before many modern studies on programming language theory. These studies provide huge advances in the creation of a language, especially in the precision and speed with which it's compiled. For example, you don't have a real range of lines and columns when there is an error or a warning in C; recent languages do.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
==History==&lt;br /&gt;
''(Feed me)''&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Language Features==&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
====Foundations====&lt;br /&gt;
'''int''': integer&amp;lt;br/&amp;gt;&lt;br /&gt;
'''char''': character&amp;lt;br/&amp;gt;&lt;br /&gt;
'''float''': float&amp;lt;br/&amp;gt;&lt;br /&gt;
'''double''': double float&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''short''': shorter type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''long''': longer type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''signed''': signed type&amp;lt;br/&amp;gt;&lt;br /&gt;
'''unsigned''': unsigned type&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
====Constants====&lt;br /&gt;
(Feed me)&lt;br /&gt;
&lt;br /&gt;
====Operators====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
===Control structures===&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
====Instruction chunks====&lt;br /&gt;
(Feed me)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
====''if (else)'' instruction====&lt;br /&gt;
The general look of a C if-then-else statement is something like&amp;lt;br&amp;gt;&lt;br /&gt;
 if(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
    &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt;&lt;br /&gt;
 } else {&lt;br /&gt;
    &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
If &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is different from 0 then &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; (whatever that might be) is executed, otherwise, that is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is 0, &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is executed. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The real issue here is of course; what is &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;, &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt;. &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is from the compilers point of view any value that can be interpreted as a number, that's almost anything in C. For instance the value 2 would be syntactically correct. The key issue is that 2 is different from 0, thus &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; would be executed. &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;B&amp;lt;/i&amp;gt; is any piece of code actually, for example &amp;lt;tt&amp;gt;printf(&amp;quot;Hello World!&amp;quot;);&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here are some ideas about what &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; could be: &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Typical cases, testing values: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 a == b // test if a has the same value as b, if so &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; is executed&lt;br /&gt;
 a != b // test if a is different from b, if so &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt; is executed&lt;br /&gt;
 a &amp;gt; b  // test if a is greater than b, if so &amp;lt;i&amp;gt;A&amp;lt;/i&amp;gt;... (you get the  drift)&lt;br /&gt;
 a &amp;lt; b  // test if a is less than b&lt;br /&gt;
 a &amp;gt;= b // test if a is greater or equal than b&lt;br /&gt;
 a &amp;lt;= b // test if a is less or equal than b&lt;br /&gt;
&lt;br /&gt;
Further you can do logical operations as well. The key concept is that everything different from 0 is true, and 0 is false. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 a &amp;amp;&amp;amp; b // test if a AND b are true, that is different from 0&lt;br /&gt;
 a || b // test if a OR  b are true &lt;br /&gt;
 a ^ b  // exclusive-OR; true if either a or b is true, false if both are true&lt;br /&gt;
 !a     // test if the negation of a is true&lt;br /&gt;
&lt;br /&gt;
Note that a and b can be any expression that returns a value, and may affect the values of variables in the course of generating those values.  It is important to realise that '''C''' stops processing an expression as soon as the answer is known for sure -- ''not every sub-expression in a compound expression will necessarily be evaluated''.  For example, if we have an expression such as&lt;br /&gt;
&lt;br /&gt;
if ((a &amp;amp;&amp;amp; b) || c) {&lt;br /&gt;
&lt;br /&gt;
if ''a'' is false, ''b'' will not be evaluated  (because a &amp;amp;&amp;amp; b cannot possibly be true if ''a'' is false).  But ''c'' will have to be evaluated, because we do not know the result in advance.  If ''a'' is true, ''b'' will be evaluated; and if ''b'' is also true, then ''c'' will ''not'' be evaluated, since we know that the result of the OR operation will be true.&lt;br /&gt;
&lt;br /&gt;
Here's a more comprehensive example of an if statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 if(customers &amp;gt; 0){&lt;br /&gt;
     printf(&amp;quot;There are people in the shop&amp;quot;); // state the obvious &lt;br /&gt;
     getHelp(); // call some functions that gets more personnel&lt;br /&gt;
 } else {&lt;br /&gt;
     drinkMoreCoffee(); // do what you're trained to do&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==== quick form of ''if'' statement ====&lt;br /&gt;
 if (a) {&lt;br /&gt;
         b&lt;br /&gt;
 } else {&lt;br /&gt;
         c&lt;br /&gt;
 }&lt;br /&gt;
is such a useful construct that there is a shorthand way to write it, which is especially handy when ''a'', ''b'' and ''c'' are all quite short expressions.  This is&lt;br /&gt;
 a ? b : c;&lt;br /&gt;
If ''a'' is true, ''b'' is evaluated; otherwise, ''c'' is evaluated.  Note that (a ? b : c) returns a value  (from ''b'' or ''c'' as appropriate)  and can be assigned to a variable or passed to a function as required.&lt;br /&gt;
&lt;br /&gt;
====''while (do)'' instruction====&lt;br /&gt;
The general look of while statement: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;){&lt;br /&gt;
     do something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is the same thing as with if statements, i.e. something that can be evaluated either true (different from zero) or false (that is zero). What's happening here is that we first test if &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true, if so the body of the while statement is executed as long as &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true. For example:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 5){&lt;br /&gt;
     a++; &lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, a); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
This would produce the output:&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1, 2, 3, 4, 5,&lt;br /&gt;
&lt;br /&gt;
Key note is that weather a is less than 5 or not is just tested in the beginning of the while loop, so it's possible to write the number 5. Then of course the loop is terminated. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The brother while loop is the so called do-while-loop&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 do {&lt;br /&gt;
     do something &lt;br /&gt;
 } while(&amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt;); &lt;br /&gt;
&lt;br /&gt;
The key note here is that weather &amp;lt;i&amp;gt;expression&amp;lt;/i&amp;gt; is true or not is tested at the end of the loop, that means that the body of the loop is executed at least once. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It's of cource possible to construct a loop that runs forever. For example: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 int a = 0; &lt;br /&gt;
 while(a &amp;lt; 3){&lt;br /&gt;
    printf(&amp;quot;I'm a fruitcake\n&amp;quot;); &lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
====''for'' instruction====&lt;br /&gt;
The general look of a for-loop is:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(A,B,C){&lt;br /&gt;
     fo something&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here A is executed just once when we enter the for-loop, typically to initialize some variables. B is a truth conditional like the ones in the while loop, if B is true then we continue looping. C is executed every time at the end of the loop. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(i = 0; i &amp;lt; 5; i++){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i); &lt;br /&gt;
 }&lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
This would produce the output: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 0, 1, 2, 3, 4,&lt;br /&gt;
&lt;br /&gt;
to guide you through it: First i is set to 0, this happens just once. Then we test if i is less than 5, clearly, it's 0. Now we enter the for-loop and print the value of, i. At the end of the loop i is incremented by 1. Then test again weather i is less than 5, print it's values, and so on. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Please note that A, B and C can all be omitted, This is valid syntax: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 for(;;){&lt;br /&gt;
     printf(&amp;quot;I'm looping forever and I'm happy with it.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It's not too common to introduce loops like this, but it works. The idea is that you can do something like: &lt;br /&gt;
&lt;br /&gt;
 int i = 0; &lt;br /&gt;
 for(;i &amp;lt; 10; printf(&amp;quot;Hello&amp;quot;)){&lt;br /&gt;
     i++; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Also you can do more things in A and C, For example you want to initialize variables i to 0 and j to 5 at the beginning of the loop. &lt;br /&gt;
&lt;br /&gt;
 for(i = 1, j = 5; (i*j) &amp;gt; 0; j++, j--){&lt;br /&gt;
     printf(&amp;quot;%d, &amp;quot;, i*j); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The , between i = 0 and j = 5 is the separator here. Same style goes at the end where j is incremented and j decremented. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Functions===&lt;br /&gt;
&lt;br /&gt;
Fisrt of all a function can be thought of as a way to store a procedure. This procedure contains some instructions that you want to carry out many times. Also it's a way to structure your program. It can also be regarded as a function in a more mathematical sense. Here is the general outfit of a C function: &lt;br /&gt;
&lt;br /&gt;
 return_type function_name(argument_1, argeument_2, ..., argument_n){&lt;br /&gt;
     function_body&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
A simple example of a function: &lt;br /&gt;
&lt;br /&gt;
 int max_i(int a, int b){&lt;br /&gt;
     if(a &amp;gt; b){&lt;br /&gt;
         return a;&lt;br /&gt;
     }&lt;br /&gt;
     return b; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can of course call other functions, for example: &lt;br /&gt;
&lt;br /&gt;
 int find_max(int *nums, int len){&lt;br /&gt;
     int max = 0, i; &lt;br /&gt;
     for(i = 0; i &amp;lt; len; i++){&lt;br /&gt;
         max = max_i(nums[i], max); &lt;br /&gt;
     }&lt;br /&gt;
     return max; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Further functions can call themselves, this example calculates n!. &lt;br /&gt;
&lt;br /&gt;
 int fac(int n){&lt;br /&gt;
     if(n == 1){&lt;br /&gt;
         return 1; &lt;br /&gt;
     }&lt;br /&gt;
     return n*fac(n - 1); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Functions can return all basic types such as, int, float, double, char, etc. They can also return pointers to all these. They can return pointers to structs and void. If a function is declared to return void it simply returns nothing. Don't confuse this with functions that returns pointers to void, that is void*. returning void* is simply returning a general pointer to something we don't the type of. &lt;br /&gt;
&lt;br /&gt;
An example of a function that 'returns' void. &lt;br /&gt;
&lt;br /&gt;
 void printObvious(){&lt;br /&gt;
     pritnf(&amp;quot;I'm a function that returns nothing.\n&amp;quot;); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
As we can see we can omitt the return statement since this function do not return anything. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
===Array and pointers===&lt;br /&gt;
(Feed me)&lt;br /&gt;
&lt;br /&gt;
===Structures===&lt;br /&gt;
(Feed me)&lt;br /&gt;
&lt;br /&gt;
==Further Reading==&lt;br /&gt;
&lt;br /&gt;
===Wiki pages===&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Books==&lt;br /&gt;
*''C Programming Language'', Brian W. Kernighan, [[Dennis Ritchie]]&lt;br /&gt;
*''C: A Reference Manual'', Samuel P. Harbison, Guy L. Steele&lt;br /&gt;
&lt;br /&gt;
==Tutorial Material==&lt;br /&gt;
Since this page serves as something of lanaguage overview more lengthy examples would fit better on it's own page. Check out [[CProgrammingExamples]] for some examples, that might help you getting started with C programming. &lt;br /&gt;
&lt;br /&gt;
''This article is a [[LinuxQuestions.org_Wiki:stub_articles|stub]] and needs to be finished. [[LinuxQuestions.org_Wiki:plunging_forward|Plunge forward]] and [[LinuxQuestions.org_Wiki:How_to_edit_a_page|help it grow]] !''&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=6112</id>
		<title>Bash tips</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=6112"/>
		<updated>2004-03-18T17:16:55Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: added bracket matcher&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==== Some General Comments ====&lt;br /&gt;
If you type in a rather long and complex [[command]] at the [[command line]], you might want to save that command in a [[text file]], so you can execute it later without having to type the whole long thing in again. If you add a line to the beginning of that file, like &amp;quot;&amp;lt;tt&amp;gt;#!/bin/bash&amp;lt;/tt&amp;gt;&amp;quot; (a so-called &amp;quot;[[shebang]]&amp;quot; line), and then make the file executable with the &amp;lt;tt&amp;gt;[[chmod]]&amp;lt;/tt&amp;gt; command, you've just created a shell script.&lt;br /&gt;
&lt;br /&gt;
Here's an example shell script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Any line that starts with a hash, besides the shebang line, is a comment.&lt;br /&gt;
echo &amp;quot;Hello world!&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run the [[shell script]] just like any other [[executable]]. Some folks create a &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory in their home directory within which to place their scripts. Others drop them in &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Some key points to keep in mind about shell scripts:&lt;br /&gt;
* They execute their commands, line by line, just as if you'd typed them in yourself at the command line.&lt;br /&gt;
* The commands in the script run in a [[subshell]] of the shell from which you executed the script.&lt;br /&gt;
* Don't put spaces around equal signs.&lt;br /&gt;
&lt;br /&gt;
You could check out the [[bash]] page and you'll also find lots of info in the [http://www.tldp.org/LDP/abs/html Advanced Bash-Scripting Guide].&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Get your IP address====&lt;br /&gt;
&lt;br /&gt;
A [[bash]] example to get your IP address using http://www.whatismyip.com:&amp;lt;br /&amp;gt;&lt;br /&gt;
 lynx -dump http://www.whatismyip.com | awk '/^Your IP is/ { print $4; }' &lt;br /&gt;
&lt;br /&gt;
Or use this:&amp;lt;br&amp;gt;&lt;br /&gt;
 /sbin/ifconfig ppp0 | awk '/inet/{ printf(&amp;quot;%s\n&amp;quot;, substr($2,index($2,&amp;quot;:&amp;quot;)+1)) }'&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that ppp0 stands for the first point-to-point-protocol device which is usually a modem. If you are using an ethernet adapter instead, replace ppp0 with eth0. You can also leave it out all together to list all the addresses associated with your computer.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Some counting examples====&lt;br /&gt;
 x=0; ((x++))&lt;br /&gt;
 x=0; x=$((x+1))&lt;br /&gt;
 x=0; let x=$x+1&lt;br /&gt;
 for (( x=0; x&amp;lt;10; x++ )) ; do echo $x ; done&lt;br /&gt;
&lt;br /&gt;
 for x in `seq 0 9`; do echo $x; done &lt;br /&gt;
 x=0; x=$(expr $x + 1) &lt;br /&gt;
 x=0; x=$(echo $x + 1|bc)&lt;br /&gt;
 x=4; x=$(echo scale=5\; $x / 3.14|bc)&lt;br /&gt;
&lt;br /&gt;
The first four demonstrate Bash' internal counting mechanisms, these will not use external programs and are thus safe (and fast).&lt;br /&gt;
The last four use external programs. [[bc]], as used in the last two examples, is the only one that supports numbers with decimals. For adding, subtracting and multiplying, you don't have to do anything special, but for division you need to specify the number of digits to keep (default is none) using the 'scale=n' line. &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Combining multiple conditions of if statements====&lt;br /&gt;
AND:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if(a==1 &amp;amp;&amp;amp; b==2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OR:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if(( a==1|2|3 ))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Renaming a set of files====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;for f in oldname* ; do mv $f ${f/oldname/newname} ; done&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[mmv]] is a really nifty tool for doing this sort of thing more flexibly too.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Extracting addresses from a mailbox file====&lt;br /&gt;
This statement will pull out everything that looks like an e-mail address from a mailbox file  (here called ''foo''), and sort them into alphabetical order.&lt;br /&gt;
  awk '!/essage-[iI][dD]/ &amp;amp;amp;&amp;amp;amp; !/MAILER-DAEMON/ {&lt;br /&gt;
    if (match($0, /([A-Za-z][A-Za-z0-9._-]*@[A-Za-z0-9._-]+)/))&lt;br /&gt;
      print substr($0, RSTART, RLENGTH); }' ''foo'' |sort |uniq&lt;br /&gt;
The &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; script works as follows.  If the line is not a message-id header, does not mention &amp;quot;MAILER-DAEMON&amp;quot;, and has something in it that looks like an email address, then the address-like portion is extracted and printed.&lt;br /&gt;
The output from &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; is sorted alphabetically by &amp;lt;tt&amp;gt;sort&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;uniq&amp;lt;/tt&amp;gt; deletes repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Converting several wav files to mp3====&lt;br /&gt;
This statement will convert all .wav files in a directory to mp3  (assuming you already have the [[http://lame.sourceforge.net/ lame]] package installed):&lt;br /&gt;
:&amp;lt;tt&amp;gt;for i in *.wav; do lame -h $i &amp;amp;amp;&amp;amp;amp; rm $i; done&amp;lt;/tt&amp;gt;&lt;br /&gt;
The double ampersand prevents rm from deleting files that weren't successfully converted.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Full file name====&lt;br /&gt;
Prints the full filename removing ./ and ../ and adding `pwd` if necessary. I keep this in a script called &amp;lt;tt&amp;gt;fqn&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
# return the full filename, removing ./ ../ adding `pwd` if necessary&lt;br /&gt;
&lt;br /&gt;
FILE=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# file		dot relative&lt;br /&gt;
# ./file	dot relative&lt;br /&gt;
# ../file	parent relative&lt;br /&gt;
# /file		absolute&lt;br /&gt;
while true; do&lt;br /&gt;
	case &amp;quot;$FILE&amp;quot; in&lt;br /&gt;
		( /* ) 		&lt;br /&gt;
		# Remove /./ inside filename:&lt;br /&gt;
		while echo &amp;quot;$FILE&amp;quot; |fgrep &amp;quot;/./&amp;quot; &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; do&lt;br /&gt;
			FILE=`echo &amp;quot;$FILE&amp;quot; | sed &amp;quot;s/\\/\\.\\//\\//&amp;quot;`&lt;br /&gt;
		done&lt;br /&gt;
		# Remove /../ inside filename:&lt;br /&gt;
		while echo &amp;quot;$FILE&amp;quot; |grep &amp;quot;/[^/][^/]*/\\.\\./&amp;quot; &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; do&lt;br /&gt;
			FILE=`echo &amp;quot;$FILE&amp;quot; | sed &amp;quot;s/\\/[^/][^/]*\\/\\.\\.\\//\\//&amp;quot;`&lt;br /&gt;
		done&lt;br /&gt;
		echo &amp;quot;$FILE&amp;quot;&lt;br /&gt;
		exit 0&lt;br /&gt;
		;;&lt;br /&gt;
		&lt;br /&gt;
		(*)&lt;br /&gt;
		FILE=`pwd`/&amp;quot;$FILE&amp;quot;&lt;br /&gt;
		;;&lt;br /&gt;
	esac&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
====Resolving a link====&lt;br /&gt;
This little script follows symbolic links wherever they may lead and prints the ultimate filename (if it exists!) (note - it uses the previous script accessed as &amp;lt;tt&amp;gt;fqn&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
# prints the real file pointed to by a link&lt;br /&gt;
# usage: $0 link&lt;br /&gt;
&lt;br /&gt;
ORIG_LINK=&amp;quot;$1&amp;quot;&lt;br /&gt;
LINK=`fqn &amp;quot;$1&amp;quot;`&lt;br /&gt;
while [ -h &amp;quot;$LINK&amp;quot; ]; do&lt;br /&gt;
	DIR=`dirname &amp;quot;$LINK&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
	# next link is everything from &amp;quot;-&amp;gt; &amp;quot;&lt;br /&gt;
	LINK=`ls -l &amp;quot;$LINK&amp;quot; |sed &amp;quot;s/^.*-&amp;gt; //&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
	LINK=`cd &amp;quot;$DIR&amp;quot;; fqn &amp;quot;$LINK&amp;quot;`&lt;br /&gt;
	if [ ! -e &amp;quot;$LINK&amp;quot; ]; then&lt;br /&gt;
		echo &amp;quot;\&amp;quot;$ORIG_LINK\&amp;quot; is a broken link: \&amp;quot;$LINK\&amp;quot; does not exist&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
		exit 1&lt;br /&gt;
	fi&lt;br /&gt;
done&lt;br /&gt;
echo &amp;quot;$LINK&amp;quot;&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
====Viewing a file according to its type====&lt;br /&gt;
I save this as a script called &amp;lt;tt&amp;gt;v&amp;lt;/tt&amp;gt; and it is my universal viewing script - it can be extended to any kind of file and to use your favourite tools for each type of file. It uses the &amp;lt;tt&amp;gt;file&amp;lt;/tt&amp;gt; utility to determine what sort of file it is and then invokes the correct tool. It automatically adapts to being used on the system console or under X.&lt;br /&gt;
&lt;br /&gt;
(note - this uses a prior script &amp;lt;tt&amp;gt;fqn&amp;lt;/tt&amp;gt;)&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&lt;br /&gt;
#! /bin/sh&lt;br /&gt;
# View files based on the type of the first one:&lt;br /&gt;
# Relies partly on 'less' to invoke an appropriate viewer.&lt;br /&gt;
# Make sure than you have this set:&lt;br /&gt;
# LESSOPEN=&amp;quot;|lesspipe.sh %s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FIRST=&amp;quot;$1&amp;quot;&lt;br /&gt;
FULL=`fqn $FIRST`&lt;br /&gt;
&lt;br /&gt;
# if we are being piped to, just run less&lt;br /&gt;
[ -z &amp;quot;$FIRST&amp;quot; -o ! -r &amp;quot;$FIRST&amp;quot; ] &amp;amp;&amp;amp; exec less &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# some file types beyond what /usr/bin/lesspipe.sh handles:&lt;br /&gt;
case &amp;quot;$FIRST&amp;quot; in&lt;br /&gt;
  *.cpio.bz2) bunzip2 -c $1 | cpio -ctv 2&amp;gt;/dev/null |less; exit ;;&lt;br /&gt;
  *.cpio) cpio -ctv $1 2&amp;gt;/dev/null |less; exit;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TYPE=`file -L -i &amp;quot;$FIRST&amp;quot;  2&amp;gt;/dev/null | \&lt;br /&gt;
  awk '{len=length(&amp;quot;'&amp;quot;$FIRST&amp;quot;'&amp;quot;)+ 2; $0=substr($0, len); print $1;}'`&lt;br /&gt;
echo &amp;quot;Type=\&amp;quot;$TYPE\&amp;quot;&amp;quot;&lt;br /&gt;
case &amp;quot;$TYPE&amp;quot; in&lt;br /&gt;
    image/jpeg | image/tiff | image/gif | image/x-xpm | image/*)&lt;br /&gt;
        xzgv &amp;quot;$@&amp;quot; ;;&lt;br /&gt;
    application/pdf) &lt;br /&gt;
	XPDFGEOM=`xdpyinfo |awk '/dimensions/ {print $2}'| \&lt;br /&gt;
          awk -Fx '{printf(&amp;quot;%dx%d+0+0&amp;quot;, 0.60*$1, $2-35)}'`&lt;br /&gt;
	xpdf -geometry $XPDFGEOM -z width &amp;quot;$@&amp;quot; &lt;br /&gt;
	;;&lt;br /&gt;
    application/postscript)&lt;br /&gt;
        gv &amp;quot;$@&amp;quot; ;;&lt;br /&gt;
    application/msword)&lt;br /&gt;
        if [ -z &amp;quot;$DISPLAY&amp;quot; ] ; then antiword &amp;quot;$@&amp;quot; | \&lt;br /&gt;
          less; else soffice &amp;quot;$@&amp;quot; &amp;amp; fi ;;&lt;br /&gt;
    text/html)&lt;br /&gt;
        if [ -z &amp;quot;$DISPLAY&amp;quot; ] ; then lynx &amp;quot;$@&amp;quot;; else dillo &amp;quot;$FULL&amp;quot; &amp;amp; fi ;;&lt;br /&gt;
    audio/mpeg)&lt;br /&gt;
        mpg123 &amp;quot;$FIRST&amp;quot; ;;&lt;br /&gt;
    *)&lt;br /&gt;
        less &amp;quot;$@&amp;quot; ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Finding the 50 largest directories====&lt;br /&gt;
&lt;br /&gt;
 du -S / | sort -nr | head -n50&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Auto-generating a shebang line====&lt;br /&gt;
:&amp;lt;tt&amp;gt;(echo -n '#!'; which perl; tail -n+2 foo) &amp;gt; bar&amp;lt;/tt&amp;gt;&lt;br /&gt;
This will print &amp;quot;#!&amp;quot; and the path to &amp;lt;tt&amp;gt;perl&amp;lt;/tt&amp;gt;, then everything except the first line (the original shebang) of the file &amp;lt;tt&amp;gt;foo&amp;lt;/tt&amp;gt;; and redirect all that to go into a file &amp;lt;tt&amp;gt;bar&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This is really meant for use in install scripts; obviously you know where perl is on your system, but not necessarily on anybody else's system  (though &amp;lt;tt&amp;gt;/usr/bin/perl&amp;lt;/tt&amp;gt; is a safe guess).  But you know bash is always at &amp;lt;tt&amp;gt;/bin/sh&amp;lt;/tt&amp;gt;.  So, instead of just saying in the documentation &amp;quot;change the first line .....&amp;quot;, you can write a little shell script that puts the correct shebang line in the file and copies it to &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt;.  Then, put this script in a .tar.gz file with your perl script and any documentation.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Creating an audio CD from .mp3 files====&lt;br /&gt;
This little script requires the mpg123 and [[http://cdrdao.sourceforge.net/ cdrdao]] packages.  It uses mpg123 to create a .wav file from each mp3 in the current directory, and builds up a &amp;quot;TOC&amp;quot; file (Table Of Contents) as it goes along, using the &amp;amp;amp;&amp;amp;amp; notation to be sure only to include successfully-converted files.  Finally, it starts writing the CD.&lt;br /&gt;
&lt;br /&gt;
The TOC file is given a name based on the PID, and is placed in the current directory.  Neither it nor the .wav files will be deleted at the end of the script, so you can always burn another copy of the CD if you want.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;#!/bin/sh&lt;br /&gt;
tocfile=&amp;quot;cd_$$.toc&amp;quot;&lt;br /&gt;
echo &amp;quot;CD_DA&amp;quot; &amp;gt; $tocfile&lt;br /&gt;
for i in *mp3&lt;br /&gt;
 do wav=&amp;quot;`basename $i .mp3`.wav&amp;quot;&lt;br /&gt;
    mpg123 -w$wav $i\&lt;br /&gt;
    &amp;amp;&amp;amp; echo -en &amp;gt;&amp;gt;$tocfile &amp;quot;TRACK AUDIO\nFILE \&amp;quot;$wav\&amp;quot; 0\n&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
echo -e &amp;quot;TOC file still available at $tocfile&amp;quot;&lt;br /&gt;
cdrdao write $tocfile&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: in the &amp;lt;tt&amp;gt;for&amp;lt;/tt&amp;gt; statement, you might think at first sight that&lt;br /&gt;
it should be &amp;lt;tt&amp;gt;for i in *.mp3&amp;lt;/tt&amp;gt;; but Linux doesn't care about&lt;br /&gt;
filename extensions at all.  * will match a . character; therefore, *mp3&lt;br /&gt;
will match everything ending in mp3 or .mp3.  Those characters are unlikely&lt;br /&gt;
to be found on the end of anything but an mp3 file.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
==== Portable Indirection ====&lt;br /&gt;
Sometimes you need to use the value of a variable whose name is held in another variable. This is indirection. For example:&lt;br /&gt;
  for V in PATH LD_LIBRARY_PATH; do echo ${!V}; done&lt;br /&gt;
but that isn't portable to older shells, eg. the old Bourne shell. A portable way is to use the following instead of &amp;lt;tt&amp;gt;${!V}&amp;lt;/tt&amp;gt;:&lt;br /&gt;
  `eval echo \\$&amp;quot;$V&amp;quot;`&lt;br /&gt;
It's not pretty but at least it works on nearly all Unixes. &lt;br /&gt;
&lt;br /&gt;
[ someone said - &amp;quot;It does require that the variable be exported.&amp;quot; Actually no. It works without exporting V on bash and on Solaris sh ]&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Matching Curly Brackets ====&lt;br /&gt;
''I'm not really sure whether this belongs under ''bash'' or ''awk'' - so move this if you think it's in the wrong place.''&lt;br /&gt;
&lt;br /&gt;
If you indent your C, Perl or PHP code in what is commonly called &amp;quot;K&amp;amp;R style&amp;quot;, which is to say something like this&lt;br /&gt;
&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;# nested loop example&lt;br /&gt;
for ($i = 0; $i &amp;lt;= 6; ++$i) {&lt;br /&gt;
    for ($j = 0; $j &amp;lt;= $i; ++$j) {&lt;br /&gt;
        print &amp;quot;$i : $j &amp;quot;;&lt;br /&gt;
    };&lt;br /&gt;
    print &amp;quot;\n&amp;quot;;&lt;br /&gt;
};&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
i.e.  where the opening curly bracket appears on the same line as the flow-control keyword  (if, while &amp;amp;c.)  and everything up to, but not including, the closing curly bracket is indented, then you may find this useful.  I came up with it out of necessity, and thought it was just too important not to share.  All it does is display the lines with a { but no following }  (in Perl, these denote associative array indexes)  or a } with no preceding {.  In other words, just the opening and closing lines of loops, not the content.  This can help you to spot those annoying missing-bracket errors.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;awk '/({[^}]*$)|(^[^{]*})/{print}' ''foo''&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace ''foo'' with the filename to be examined.  Or, of course, you can omit the filename and use the command in a [[pipeline]].&lt;br /&gt;
&lt;br /&gt;
The above example would appear as&lt;br /&gt;
&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;for ($i = 0; $i &amp;lt;= 6; ++$i) {&lt;br /&gt;
    for ($j = 0; $j &amp;lt;= $i; ++$j) {&lt;br /&gt;
    };&lt;br /&gt;
};&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
----&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Crontab&amp;diff=4217</id>
		<title>Crontab</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Crontab&amp;diff=4217"/>
		<updated>2004-03-11T09:49:26Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==crontab==&lt;br /&gt;
The '''crontab''' command is most often invoked with the '''-e''' option, which launches your preferred editor as specified by the &amp;lt;tt&amp;gt;$EDITOR&amp;lt;/tt&amp;gt; [[environment variable]].&lt;br /&gt;
&lt;br /&gt;
Each line in the &amp;lt;tt&amp;gt;crontab&amp;lt;/tt&amp;gt; file can be a comment, a variable declaration or an event line.&lt;br /&gt;
&lt;br /&gt;
===Comments===&lt;br /&gt;
Comments begin with a comment mark #, and must be on a line by themselves.&lt;br /&gt;
&lt;br /&gt;
===Variable declarations===&lt;br /&gt;
Variable declarations are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;name=value&amp;lt;/tt&amp;gt;&lt;br /&gt;
Unlike [[bash]] scripts, you can get away with putting spaces around the '''=''' sign.  It's probably a bad habit to get into, though.&lt;br /&gt;
&lt;br /&gt;
===Event lines===&lt;br /&gt;
Each event line specifies a time and a date, and a command which is to be executed them, in the format&lt;br /&gt;
:&amp;lt;tt&amp;gt;minute hour date month day command&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first five fields can be numbers or ranges, in the format described below. Note that you can specify ''either'' the '''date''' (i.e.  within the month) ''or'' the '''day''' (of the week); the other field should be set to *.  &lt;br /&gt;
&lt;br /&gt;
The sixth field is a command with parameters.  Percent signs -- unless [[escape]]d with a \ backslash -- will be turned into newlines, and everything after the first one of these will be fed into the command's [[Stdin|standard input]] stream.&lt;br /&gt;
&lt;br /&gt;
====Range format====&lt;br /&gt;
&amp;amp;#42; = any number&lt;br /&gt;
&amp;lt;br&amp;gt;1-6 = any number between 1 and 6 inclusive.&lt;br /&gt;
&amp;lt;br&amp;gt;0-55/5 = any number 0 to 55 inclusive, in steps of 5&lt;br /&gt;
&amp;lt;br&amp;gt;1, 8, 15, 22, 29 = 1, 8, 15, 22 or 29&lt;br /&gt;
&lt;br /&gt;
====Months====&lt;br /&gt;
Months can be specified in numbers or in words.&lt;br /&gt;
&amp;lt;br&amp;gt;1 = jan&lt;br /&gt;
&amp;lt;br&amp;gt;2 = feb&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;12 = dec&lt;br /&gt;
&lt;br /&gt;
====Days of the week====&lt;br /&gt;
Days of the week also can be specified in numbers or words.&lt;br /&gt;
&amp;lt;br&amp;gt;0 = sun&lt;br /&gt;
&amp;lt;br&amp;gt;1 = mon&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;6 - sat&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
:&amp;lt;tt&amp;gt;# fetch e-mail every ten minutes&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;0-50/10 * * * * fetchmail&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;# send myself a birthday greeting&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;0 9 7 28 * mail -s'Happy Birthday' ajs318%Many Happy Returns - you old fart!%.%%&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;# back up my recipe database every Monday&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;30 5 * * 1 mysqldump --opt recipes &amp;gt; /home/ajs318/backups/recipes.sql&amp;lt;/tt&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Crontab&amp;diff=4012</id>
		<title>Crontab</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Crontab&amp;diff=4012"/>
		<updated>2004-03-09T21:58:14Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==crontab==&lt;br /&gt;
The '''crontab''' command is most often invoked with the '''-e''' option, which launches your preferred editor as specified by the &amp;lt;tt&amp;gt;$EDITOR&amp;lt;/tt&amp;gt; [[environment variable]].&lt;br /&gt;
&lt;br /&gt;
Each line in the &amp;lt;tt&amp;gt;crontab&amp;lt;/tt&amp;gt; file can be a comment, a variable declaration or an event line.&lt;br /&gt;
&lt;br /&gt;
===Comments===&lt;br /&gt;
Comments begin with a comment mark #, and must be on a line by themselves.&lt;br /&gt;
&lt;br /&gt;
===Variable declarations===&lt;br /&gt;
Variable declarations are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;name=value&amp;lt;/tt&amp;gt;&lt;br /&gt;
Unlike [[bash]] scripts, you can get away with putting spaces around the '''=''' sign.  It's probably a bad habit to get into, though.&lt;br /&gt;
&lt;br /&gt;
===Event lines===&lt;br /&gt;
Each event line specifies a time and a date, and a command which is to be executed them, in the format&lt;br /&gt;
:&amp;lt;tt&amp;gt;minute hour date month day command&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first five fields can be numbers or ranges, in the format described below. Note that you can specify ''either'' the '''date''' (i.e.  within the month) ''or'' the '''day''' (of the week); the other field should be set to *.  &lt;br /&gt;
&lt;br /&gt;
The sixth field is a command with parameters.  Percent signs -- unless [[escape]]d with a \ backslash -- will be turned into newlines, and everything after the first one of these will be fed into the command's [[STDIN|standard input]] stream.&lt;br /&gt;
&lt;br /&gt;
====Range format====&lt;br /&gt;
&amp;amp;#42; = any number&lt;br /&gt;
&amp;lt;br&amp;gt;1-6 = any number between 1 and 6 inclusive.&lt;br /&gt;
&amp;lt;br&amp;gt;0-55/5 = any number 0 to 55 inclusive, in steps of 5&lt;br /&gt;
&amp;lt;br&amp;gt;1, 8, 15, 22, 29 = 1, 8, 15, 22 or 29&lt;br /&gt;
&lt;br /&gt;
====Months====&lt;br /&gt;
Months can be specified in numbers or in words.&lt;br /&gt;
&amp;lt;br&amp;gt;1 = jan&lt;br /&gt;
&amp;lt;br&amp;gt;2 = feb&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;12 = dec&lt;br /&gt;
&lt;br /&gt;
====Days of the week====&lt;br /&gt;
Days of the week also can be specified in numbers or words.&lt;br /&gt;
&amp;lt;br&amp;gt;0 = sun&lt;br /&gt;
&amp;lt;br&amp;gt;1 = mon&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;6 - sat&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
:&amp;lt;tt&amp;gt;# fetch e-mail every ten minutes&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;0-50/10 * * * * fetchmail&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;# send myself a birthday greeting&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;0 9 7 28 * mail -s'Happy Birthday' ajs318%Many Happy Returns - you old fart!%.%%&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;# back up my recipe database every Monday&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;30 5 * * 1 mysqldump --opt recipes &amp;gt; /home/ajs318/backups/recipes.sql&amp;lt;/tt&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Crontab&amp;diff=3743</id>
		<title>Crontab</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Crontab&amp;diff=3743"/>
		<updated>2004-03-09T21:55:34Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==crontab==&lt;br /&gt;
The '''crontab''' command is most often invoked with the '''-e''' option, which launches your preferred editor as specified by the &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt;[[environment variable]].&lt;br /&gt;
&lt;br /&gt;
Each line in the &amp;lt;tt&amp;gt;crontab&amp;lt;/tt&amp;gt; file can be a comment, a variable declaration or an event line.&lt;br /&gt;
&lt;br /&gt;
===Comments===&lt;br /&gt;
Comments begin with a comment mark #, and must be on a line by themselves.&lt;br /&gt;
&lt;br /&gt;
===Variable declarations===&lt;br /&gt;
Variable declarations are of the form&lt;br /&gt;
:&amp;lt;tt&amp;gt;name=value&amp;lt;/tt&amp;gt;&lt;br /&gt;
Unlike [[bash]] scripts, you can get away with putting spaces around the '''=''' sign.  It's probably a bad habit to get into, though.&lt;br /&gt;
&lt;br /&gt;
===Event lines===&lt;br /&gt;
Each event line specifies a time and a date, and a command which is to be executed them, in the format&lt;br /&gt;
:&amp;lt;tt&amp;gt;minute hour date month day command&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first five fields can be numbers or ranges, in the format described below. Note that you can specify ''either'' the '''date''' (i.e.  within the month) ''or'' the '''day''' (of the week); the other field should be set to *.  &lt;br /&gt;
&lt;br /&gt;
The sixth field is a command with parameters.  Percent signs -- unless [[escape]]d with a \ backslash -- will be turned into newlines, and everything after the first one of these will be fed into the command's [[STDIN standard input]] stream.&lt;br /&gt;
&lt;br /&gt;
====Range format====&lt;br /&gt;
&amp;amp;#42; = any number&lt;br /&gt;
&amp;lt;br&amp;gt;1-6 = any number between 1 and 6 inclusive.&lt;br /&gt;
&amp;lt;br&amp;gt;0-55/5 = any number 0 to 55 inclusive, in steps of 5&lt;br /&gt;
&amp;lt;br&amp;gt;1, 8, 15, 22, 29 = 1, 8, 15, 22 or 29&lt;br /&gt;
&lt;br /&gt;
====Months====&lt;br /&gt;
Months can be specified in numbers or in words.&lt;br /&gt;
&amp;lt;br&amp;gt;1 = jan&lt;br /&gt;
&amp;lt;br&amp;gt;2 = feb&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;12 = dec&lt;br /&gt;
&lt;br /&gt;
====Days of the week====&lt;br /&gt;
Days of the week also can be specified in numbers or words.&lt;br /&gt;
&amp;lt;br&amp;gt;0 = sun&lt;br /&gt;
&amp;lt;br&amp;gt;1 = mon&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;6 - sat&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
:&amp;lt;tt&amp;gt;# fetch e-mail every ten minutes&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;0-50/10 * * * * fetchmail&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;# send myself a birthday greeting&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;0 9 7 28 * mail -s'Happy Birthday' ajs318%Many Happy Returns - you old fart!%.%%&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;# back up my recipe database every Monday&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;30 5 * * 1 mysqldump --opt recipes &amp;gt; /home/ajs318/backups/recipes.sql&amp;lt;/tt&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Burning_a_CDROM_from_a_bin/cue_file&amp;diff=6267</id>
		<title>Burning a CDROM from a bin/cue file</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Burning_a_CDROM_from_a_bin/cue_file&amp;diff=6267"/>
		<updated>2004-03-08T23:13:44Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: added relevant link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To burn a bin/cue (or bin/toc), use the 'cdrdao' command. Make sure that both the bin and cue files are in your current directory (you see them when typing &amp;lt;b&amp;gt;ls&amp;lt;/b&amp;gt;) when you invoke this command.&lt;br /&gt;
&lt;br /&gt;
Type &amp;lt;b&amp;gt;man cdrdao&amp;lt;/b&amp;gt; to see all options. Also see the section below on 'common options for cdrdao'.&lt;br /&gt;
&lt;br /&gt;
cdrdao will turn on burnproof/burnfree automagically if it is available on your CD recorder.&lt;br /&gt;
&lt;br /&gt;
=== Burning under kernel version 2.4 or less ===&lt;br /&gt;
&lt;br /&gt;
Assuming you set up ide-scsi setup for your 2.4 (or less) kernel as described in [[IDE_CD_Writer]], you could now invoke cdrdao as follows:&lt;br /&gt;
&lt;br /&gt;
cdrdao write --device 0,0,0 --driver generic-mmc --speed 16 NameOfCUEOrTOCFile&lt;br /&gt;
&lt;br /&gt;
=== Burning under kernel version 2.6 or higher === &lt;br /&gt;
&lt;br /&gt;
cdrdao write --device ATAPI:0,0,0 --driver generic-mmc --speed 16 NameOfCUEOrTOCFile&lt;br /&gt;
&lt;br /&gt;
=== Common options for cdrdao ===&lt;br /&gt;
&lt;br /&gt;
* The first option tells cdrdao what you want to do. cdrdao can also be used to read an existing CD and make a bin/cue image from that. But that is another topic.&lt;br /&gt;
&lt;br /&gt;
* The device command tells cdrdao where to find your CD writer. Like in described in [[Burning_a_CDROM_from_an_ISO_file]], if have a CD drive and a CD recorder, you might need to change this line (depending on the order that you have your drives in the IDE tree) to 0,1,0. See what works for you.&lt;br /&gt;
&lt;br /&gt;
* Some drives are not known to cdrdao and it won't know what driver to use, so we specify it. Most CD recorders will use generic_mmc.&lt;br /&gt;
&lt;br /&gt;
* Speed is obvious. If the cd writable medium you are using does not support a high speed, it will use that instead.&lt;br /&gt;
&lt;br /&gt;
* Lastly the name of the .cue or .toc file.&lt;br /&gt;
&lt;br /&gt;
* The simplest form of TOC file is for an audio CD where each track is to be created from a &amp;lt;tt&amp;gt;.wav&amp;lt;/tt&amp;gt; file.  This has the format&lt;br /&gt;
&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;CD_DA&lt;br /&gt;
TRACK AUDIO&lt;br /&gt;
FILE track01.wav 0&lt;br /&gt;
TRACK AUDIO&lt;br /&gt;
FILE track02.wav 0&lt;br /&gt;
...&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
See also [[Bash_tips#Creating_an_audio_CD_from_.mp3_files|here]] for a simple script to generate such a file.&lt;br /&gt;
&lt;br /&gt;
=== Mounting a BIN/CUE or IMG/CUE file ===&lt;br /&gt;
&lt;br /&gt;
To mount a BIN/CUE or IMG/CUE file you can use the 'cdemu' kernel module.&lt;br /&gt;
&lt;br /&gt;
Official website: http://cdemu.sourceforge.net/&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=3534</id>
		<title>Bash tips</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=3534"/>
		<updated>2004-03-08T17:24:55Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: added cd creation script&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==== Get your IP address====&lt;br /&gt;
&lt;br /&gt;
A [[bash]] example to get your IP address using http://www.whatismyip.com:&amp;lt;br /&amp;gt;&lt;br /&gt;
 lynx -dump http://www.whatismyip.com | awk '/^Your IP is/ { print $4; }' &lt;br /&gt;
&lt;br /&gt;
Or use this:&amp;lt;br&amp;gt;&lt;br /&gt;
 /sbin/ifconfig ppp0 | awk '/inet/{ printf(&amp;quot;%s\n&amp;quot;, substr($2,index($2,&amp;quot;:&amp;quot;)+1)) }'&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that ppp0 stands for the first point-to-point-protocol device which is usually a modem. If you are using an ethernet adapter instead, replace ppp0 with eth0. You can also leave it out all together to list all the addresses associated with your computer.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Some counting examples====&lt;br /&gt;
 x=0; ((x++))&lt;br /&gt;
 x=0; x=$((x+1))&lt;br /&gt;
 x=0; let x=$x+1&lt;br /&gt;
 for (( x=0; x&amp;lt;10; x++ )) ; do echo $x ; done&lt;br /&gt;
&lt;br /&gt;
 for x in `seq 0 9`; do echo $x; done &lt;br /&gt;
 x=0; x=$(expr $x + 1) &lt;br /&gt;
 x=0; x=$(echo $x + 1|bc)&lt;br /&gt;
 x=4; x=$(echo scale=5\; $x / 3.14|bc)&lt;br /&gt;
&lt;br /&gt;
The first four demonstrate Bash' internal counting mechanisms, these will not use external programs and are thus safe (and fast).&lt;br /&gt;
The last four use external programs. [[bc]], as used in the last two examples, is the only one that supports numbers with decimals. For adding, subtracting and multiplying, you don't have to do anything special, but for division you need to specify the number of digits to keep (default is none) using the 'scale=n' line. &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Combining multiple conditions of if statements====&lt;br /&gt;
AND:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(a==1 &amp;amp;&amp;amp; b==2)&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
OR:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(( a==1|2|3 ))&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Renaming a set of files====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;for f in oldname* ; do mv $f ${f/oldname/newname} ; done&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Extracting addresses from a mailbox file====&lt;br /&gt;
This statement will pull out everything that looks like an e-mail address from a mailbox file  (here called ''foo''), and sort them into alphabetical order.  Note, it should be typed all on one line.&lt;br /&gt;
:&amp;lt;tt&amp;gt;awk '!/essage-[iI][dD]/ &amp;amp;amp;&amp;amp;amp; !/MAILER-DAEMON/ &amp;amp;amp;&amp;amp;amp; match ($0, /([A-Za-z][A-Za-z0-9._-]*@[A-Za-z0-9._-]*)/) {print substr($0, RSTART, RLENGTH)}' ''foo'' |sort |uniq&amp;lt;/tt&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; script works as follows.  If the line is not a message-id header, does not mention &amp;quot;MAILER-DAEMON&amp;quot;, and has something in it that looks like an email address, then the address-like portion is extracted and printed.  The output from &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; is sorted alphabetically by the &amp;lt;tt&amp;gt;sort&amp;lt;/tt&amp;gt; statement, and the &amp;lt;tt&amp;gt;uniq&amp;lt;/tt&amp;gt; statement deletes repetitions.  You probably will want to divert the output to another file; if the name of this file is ''bar'' then simply add &amp;lt;tt&amp;gt;&amp;amp;gt;''bar''&amp;lt;/tt&amp;gt; to the end of the above.  But it wouldn't hurt to check that the statement works before you commit it to a file.  You can run it once, displaying everything on the screen, amd scroll back with your mouse wheel to check the output. if it looks OK, you just need to press cursor up  (which will recover the previous line for editing and position the cursor at the end of the line),  and then type the extra more-than sign and filename.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Converting several wav files to mp3====&lt;br /&gt;
This statement will convert all .wav files in a directory to mp3  (assuming you already have the [[http://lame.sourceforge.net/ lame]] package installed):&lt;br /&gt;
:&amp;lt;tt&amp;gt;for i in *.wav; do lame -h $i &amp;amp;amp;&amp;amp;amp; rm $i; done&amp;lt;/tt&amp;gt;&lt;br /&gt;
The double ampersand prevents rm from deleting files that weren't successfully converted.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Resolving a link====&lt;br /&gt;
This little script follows symbolic links wherever they may lead and prints the ultimate filename (if it exists!)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
# prints the real file pointed to by a link&lt;br /&gt;
# usage: $0 link&lt;br /&gt;
&lt;br /&gt;
ORIG_LINK=&amp;quot;$1&amp;quot;&lt;br /&gt;
LINK=`fqn &amp;quot;$1&amp;quot;`&lt;br /&gt;
while [ -h &amp;quot;$LINK&amp;quot; ]; do&lt;br /&gt;
	DIR=`dirname &amp;quot;$LINK&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
	# next link is everything from &amp;quot;-&amp;gt; &amp;quot;&lt;br /&gt;
	LINK=`ls -l &amp;quot;$LINK&amp;quot; |sed &amp;quot;s/^.*-&amp;gt; //&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
	LINK=`cd &amp;quot;$DIR&amp;quot;; fqn &amp;quot;$LINK&amp;quot;`&lt;br /&gt;
	if [ ! -e &amp;quot;$LINK&amp;quot; ]; then&lt;br /&gt;
		echo &amp;quot;\&amp;quot;$ORIG_LINK\&amp;quot; is a broken link: \&amp;quot;$LINK\&amp;quot; does not exist&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
		exit 1&lt;br /&gt;
	fi&lt;br /&gt;
done&lt;br /&gt;
echo &amp;quot;$LINK&amp;quot;&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Finding the 50 largest directories====&lt;br /&gt;
&lt;br /&gt;
 du -S / | sort -nr | head -n50&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Auto-generating a shebang line====&lt;br /&gt;
:&amp;lt;tt&amp;gt;(echo -n '#!'; which perl; tail -n+2 foo) &amp;gt; bar&amp;lt;/tt&amp;gt;&lt;br /&gt;
This will print &amp;quot;#!&amp;quot; and the path to &amp;lt;tt&amp;gt;perl&amp;lt;/tt&amp;gt;, then everything except the first line (the original shebang) of the file &amp;lt;tt&amp;gt;foo&amp;lt;/tt&amp;gt;; and redirect all that to go into a file &amp;lt;tt&amp;gt;bar&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This is really meant for use in install scripts; obviously you know where perl is on your system, but not necessarily on anybody else's system  (though &amp;lt;tt&amp;gt;/usr/bin/perl&amp;lt;/tt&amp;gt; is a safe guess).  But you know bash is always at &amp;lt;tt&amp;gt;/bin/sh&amp;lt;/tt&amp;gt;.  So, instead of just saying in the documentation &amp;quot;change the first line .....&amp;quot;, you can write a little shell script that puts the correct shebang line in the file and copies it to &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt;.  Then, put this script in a .tar.gz file with your perl script and any documentation.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Creating an audio CD from .mp3 files====&lt;br /&gt;
This little script requires the mpg123 and [[http://cdrdao.sourceforge.net/ cdrdao]] packages.  It uses mpg123 to create a .wav file from each mp3 in the current directory, and builds up a &amp;quot;TOC&amp;quot; file (Table Of Contents) as it goes along, using the &amp;amp;amp;&amp;amp;amp; notation to be sure only to include successfully-converted files.  Finally, it starts writing the CD.&lt;br /&gt;
&lt;br /&gt;
The TOC file is given a name based on the PID, and is placed in the current directory.  Neither it nor the .wav files will be deleted at the end of the script, so you can always burn another copy of the CD if you want.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;#!/bin/sh&lt;br /&gt;
tocfile=&amp;quot;cd_$$.toc&amp;quot;&lt;br /&gt;
echo &amp;quot;CD_DA&amp;quot; &amp;gt; $tocfile&lt;br /&gt;
for i in *mp3&lt;br /&gt;
 do wav=&amp;quot;`basename $i .mp3`.wav&amp;quot;&lt;br /&gt;
    mpg123 -w$wav $i\&lt;br /&gt;
    &amp;amp;&amp;amp; echo -en &amp;gt;&amp;gt;$tocfile &amp;quot;TRACK AUDIO\nFILE \&amp;quot;$wav\&amp;quot; 0\n&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
echo -e &amp;quot;TOC file still available at $tocfile&amp;quot;&lt;br /&gt;
cdrdao write $tocfile&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: in the &amp;lt;tt&amp;gt;for&amp;lt;/tt&amp;gt; statement, you might think at first sight that&lt;br /&gt;
it should be &amp;lt;tt&amp;gt;for i in *.mp3&amp;lt;/tt&amp;gt;; but Linux doesn't care about&lt;br /&gt;
filename extensions at all.  * will match a . character; therefore, *mp3&lt;br /&gt;
will match everything ending in mp3 or .mp3.  Those characters are unlikely&lt;br /&gt;
to be found on the end of anything but an mp3 file.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Debian&amp;diff=3683</id>
		<title>Debian</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Debian&amp;diff=3683"/>
		<updated>2004-03-08T09:31:26Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: it's == esta, its == su&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Debian''' is a complete free [[operating system]]. Debian uses the Linux [[kernel]] (the core of an operating system), but most of the basic OS tools come from the [[GNU]] project; hence the name GNU/Linux.&lt;br /&gt;
&lt;br /&gt;
Although it is a non-commercial project Debian is one of the most popular and well-respected Linux [[distributions]].  Advanced users are attracted to its stability, powerful [[package]] management and pure [[Open Source]] stance.&lt;br /&gt;
&lt;br /&gt;
It also supports the most number of hardware [[platforms]] - a total of 11. As well as standard [[PC]]s, Debian versions are often used on [[Macs]] ([[M68k]] and [[PPC]]), and systems from [[SUN]] ([[SPARC]]).  Debian is also the basis for the [[Familiar]] distribution for [[PDAs]]. &lt;br /&gt;
&lt;br /&gt;
Debian systems currently use the Linux kernel, however, work is in progress to provide Debian for other kernels, primarily for the Hurd. The Hurd is a collection of servers that run on top of a microkernel (such as Mach) to implement different features. The Hurd is free software produced by the GNU project.  Aside from Debian/Hurd, enterprising people can try out Debian/FreeBSD and Debian/NetBSD.&lt;br /&gt;
&lt;br /&gt;
Stable, Testing, and Unstable releases are available, codenamed &amp;quot;Woody&amp;quot;,&amp;quot;Sarge&amp;quot;, and &amp;quot;Sid&amp;quot; (respectively) at the moment.  When the current Testing cycle ends, Sarge will become Stable, and a new name will be chosen for Testing.  Under current policy, Sid will remain Sid forever because someone noticed that not only is it named after the kid who breaks toys, it also stands for Still In Development.  Debian follows a very strict guideline on which [[packages]] are allowed in each version, and this is what makes Stable, Stable.  These guidelines are spelled out in the [http://www.debian.org/doc/debian-policy/ Debian Policy Manual], which includes the Debian Free Software Guidelines.&lt;br /&gt;
&lt;br /&gt;
The base system contains very little, typically just enough to download the rest of whatever is needed for the system, and users must use [[Apt]] to get most packages, such as the [[X Window System]].  This format allows Debian to be installed on many older computers where space is scarce, and only the packages that will be used should be installed.  While CD images for Woody/Stable exist, the preferred method for systems with an internet connection is to use the base system (which can be downloaded in the form of a netinst CD for Woody or Sarge), and install whatever is necessary over the network using Apt.  There are several front-ends to Apt to make the job easier (or at least to help you guess what packages are named), the most common of which is &amp;lt;tt&amp;gt;[[dselect]]&amp;lt;/tt&amp;gt; since it is always on every Debian distribution (and even predates Apt).&lt;br /&gt;
&lt;br /&gt;
Debian was begun in August 1993 by Ian Murdock, as a new distribution which would be made openly, in the spirit of Linux and GNU. &lt;br /&gt;
&lt;br /&gt;
Since many people have asked, Debian is pronounced 'deb ee n'. It comes from the names of the creator of Debian, Ian Murdock, and his wife, Debra.&lt;br /&gt;
&lt;br /&gt;
Official website: http://www.debian.org&amp;lt;br&amp;gt;&lt;br /&gt;
Debian wiki: http://wiki.debian.net&amp;lt;br&amp;gt;&lt;br /&gt;
Security information is available in the Debian section of: [[Obtaining security updates]]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Perl&amp;diff=3535</id>
		<title>Perl</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Perl&amp;diff=3535"/>
		<updated>2004-03-07T21:32:55Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Perl ==&lt;br /&gt;
=== What is Perl ===&lt;br /&gt;
&lt;br /&gt;
''Practical Extraction and Report Language''. Some people prefer ''Pathologically Eclectic Rubbish Lister''. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;From the perldoc&amp;lt;/i&amp;gt;:&amp;lt;br&amp;gt;&lt;br /&gt;
Perl is a high-level programming language with an eclectic heritage written by Larry Wall and a cast of thousands. It derives from the ubiquitous C programming language and to a lesser extent from sed, awk, the Unix shell, and at least a dozen other tools and languages. Perl's process, file, and text manipulation facilities make it particularly well-suited for tasks involving quick prototyping, system utilities, software tools, system management tasks, database access, graphical programming, networking, and world wide web programming. These strengths make it especially popular with system administrators and CGI script authors, but mathematicians, geneticists, journalists, and even managers also use Perl. Maybe you should, too.&lt;br /&gt;
&lt;br /&gt;
=== Sample Perl Program ===&lt;br /&gt;
&amp;amp;#35!/usr/bin/perl -w &amp;lt;br&amp;gt;&lt;br /&gt;
print &amp;quot;Hello World!\n&amp;quot;;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
The first line is the [[shebang]] line, it identifies the location of perl. If you don't know where perl is located, you can type '&amp;lt;b&amp;gt;which perl&amp;lt;/b&amp;gt;' and it should show you where it is. If perl is not in your path or installed on your system it will show you nothing. Most distributions come with perl already installed. &lt;br /&gt;
&lt;br /&gt;
The print line displays the text and the \n is a special character indicating the new line. &lt;br /&gt;
&lt;br /&gt;
=== CPAN ===&lt;br /&gt;
One of the greatest resources for any perl programmer is http://www.cpan.org which is a collection of perl modules which you can use in your own programs to simplify many things. &lt;br /&gt;
&lt;br /&gt;
=== Useful Links ===&lt;br /&gt;
http://www.perl.com &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.perlmonks.org&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Perl and CGI scripting==&lt;br /&gt;
Perl is commonly used for writing CGI scripts; basically, scripts that run on a web server.  If a file is suitably declared, instead of its contents being displayed, it is executed and its ''output'' displayed.  Data from forms can be passed to CGI scripts.&lt;br /&gt;
&lt;br /&gt;
CGI scripts are usually placed in a directory called &amp;lt;tt&amp;gt;cgi-bin&amp;lt;/tt&amp;gt;.  Check your distribution's  (or your ISP's)  documentation to discover where this directory is.  Make sure the script has its permissions set to 755.&lt;br /&gt;
&lt;br /&gt;
===Simple CGI script===&lt;br /&gt;
&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;#!/usr/bin/perl&lt;br /&gt;
print &amp;quot;Content-type: text/html\n\n&amp;quot;;&lt;br /&gt;
print &amp;quot;&amp;lt;HTML&amp;gt;\n&amp;quot;;&lt;br /&gt;
print &amp;quot;&amp;lt;BODY&amp;gt;\n&amp;quot;;&lt;br /&gt;
print &amp;quot;Hello, world!\n&amp;quot;;&lt;br /&gt;
print &amp;quot;&amp;lt;/BODY&amp;gt;\n&amp;quot;;&lt;br /&gt;
print &amp;quot;&amp;lt;/HTML&amp;gt;\n&amp;quot;;&lt;br /&gt;
exit;&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
Note the first line we print is a MIME type.  If httpd were sending a regular file, it would determine what type of file it is from the first few bytes and send a MIME type automatically; but a CGI script is expected to send its own MIME type.  (That sounds like a minus, but it also means that a script can easily send additional HTTP headers if necessary.)  The second line is a blank line, to terminate the headers.  The remainder is just a short, pointless HTML file.&lt;br /&gt;
&lt;br /&gt;
===A form reader===&lt;br /&gt;
The following programme reads and displays data from HTML forms.  It's useful for debugging purposes, or for using as the basis for a more complicated script,&lt;br /&gt;
&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
use strict;&lt;br /&gt;
&lt;br /&gt;
my $input_buffer,&lt;br /&gt;
my (@post_names,@get_names);&lt;br /&gt;
my %parameters;&lt;br /&gt;
my ($name, $value);&lt;br /&gt;
my $referrer = $ENV{'HTTP_REFERER'};&lt;br /&gt;
&lt;br /&gt;
foreach (split/&amp;amp;/, $ENV{'QUERY_STRING') {&lt;br /&gt;
    tr/+/ /;&lt;br /&gt;
    ($name,$value) = split /=/, $_;&lt;br /&gt;
    $name  =~ s/%(..)/pack('c', hex($1))/eg;&lt;br /&gt;
    $value =~ s/%(..)/pack('c', hex($1))/eg;&lt;br /&gt;
    $parameters{$name} = $value;&lt;br /&gt;
    push @get_names,$name;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
foreach (split /&amp;amp;/, (read STDIN,$input_buffer,$ENV{&amp;quot;CONTENT_LENGTH&amp;quot;})) {&lt;br /&gt;
    tr/+/ /;&lt;br /&gt;
    ($name,$value) = split (/=/, $_);&lt;br /&gt;
    $name  =~ s/%(..)/pack('c', hex($1))/eg;&lt;br /&gt;
    $value =~ s/%(..)/pack('c', hex($1))/eg;&lt;br /&gt;
    push @post_names,$name;&lt;br /&gt;
    $parameters{$name} = $value;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
print &amp;lt;&amp;lt; &amp;quot;--STOP--&amp;quot;;&lt;br /&gt;
Content-type: text/html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;HTML&amp;gt;&lt;br /&gt;
&amp;lt;HEAD&amp;gt;&amp;lt;TITLE&amp;gt;General Purpose Form Reader&amp;lt;/TITLE&amp;gt;&amp;lt;/HEAD&amp;gt;&lt;br /&gt;
&amp;lt;BODY&amp;gt;&lt;br /&gt;
&amp;lt;H1&amp;gt;General Purpose Form Reader&amp;lt;/H1&amp;gt;&lt;br /&gt;
--STOP--&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Referring page was \&amp;quot;$referrer\&amp;quot;&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
if (@get_names) {&lt;br /&gt;
    print &amp;quot;&amp;lt;BR&amp;gt;Items submitted by GET / query string  (in order):\n&amp;quot;;&lt;br /&gt;
    foreach (@get_names) {&lt;br /&gt;
        print &amp;quot;&amp;lt;BR&amp;gt;&amp;amp;quot;$_&amp;amp;quot; = &amp;amp;quot;$parameters{$_}&amp;amp;quot;\n&amp;quot;;&lt;br /&gt;
    };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
if (@post_names) {&lt;br /&gt;
    print &amp;quot;&amp;lt;BR&amp;gt;Items submitted by POST method  (in order):\n&amp;quot;;&lt;br /&gt;
    foreach (@post_names) {&lt;br /&gt;
        print &amp;quot;&amp;lt;BR&amp;gt;&amp;amp;quot;$_&amp;amp;quot; = &amp;amp;quot;$parameters{$_}&amp;amp;quot;\n&amp;quot;;&lt;br /&gt;
    };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
if (!(@get_names) &amp;amp;&amp;amp; !(@post_names)) {&lt;br /&gt;
    print &amp;quot;&amp;lt;BR&amp;gt;Nothing was submitted!\n&amp;quot;;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;&amp;lt;/BODY&amp;gt;\n&amp;lt;/HTML&amp;gt;\n&amp;quot;;&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first section simply sets up some variables.  The next section reads the value of the query string, which is stored in the environment variable QUERY_STRING; splits it into name/value pairs; and parses special characters in the names and values -- this needs to be done ''after'' the split, in case one of the special characters evaluates to an = sign.  Yes, I made that mistake, and now I'm telling you about it so you don't have to.  The names are stored in an array  (which is only really necessary for the purposes of keeping the GET and POST variables separate; feel free to drop it in a &amp;quot;real life&amp;quot; script if you don't care how the variables got there),  and an associative array is constructed, with the values indexed by name.  &lt;br /&gt;
&lt;br /&gt;
The next section reads the POST data, if any, and sotes it similarly:  names into an array, vaules into the same associative array.  This is passed through STDIN; an environment variable, CONTENT_LENGTH, is set to hold the length of the data.  Again, the data consists of a set of name=value pairs, separated by &amp;amp;amp; signs.&lt;br /&gt;
&lt;br /&gt;
Finally, a web page is started, and the GET and POST values are printed in turn.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Shebang&amp;diff=3555</id>
		<title>Shebang</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Shebang&amp;diff=3555"/>
		<updated>2004-03-07T13:28:15Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=A_basic_firewall_configuration_suitable_for_a_gateway/nat&amp;diff=3218</id>
		<title>A basic firewall configuration suitable for a gateway/nat</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=A_basic_firewall_configuration_suitable_for_a_gateway/nat&amp;diff=3218"/>
		<updated>2004-03-07T13:16:09Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: added Debian-specific notes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== NAT Gateway ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
The field of application of a [[NAT]] Gateway is in example a private [[LAN]] consisting of several [[PC]]s with an [[Internet]] connection with one public [[IP address]].&lt;br /&gt;
* The goal is to share the Internet connection among the LAN PCs.&lt;br /&gt;
* The problem is that there is only one public IP for outbound traffic.&lt;br /&gt;
* The solution is &amp;quot;''Network Address Translation''&amp;quot; (or NAT for short).&amp;lt;br&amp;gt;&lt;br /&gt;
The Gateway (GW) is equipped with two network interfaces. One gets assigned the public IP, the second a private IP (i.e. 192.168.0.1). Every other LAN PCs has it's own private IP (i.e. 192.168.0.2). If an outbound connection is requested the LAN PC talks to the gateway which masquerades the outbound traffic using the public IP. So every external connection looks like if it is coming from only one PC.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The basic firewalling will prevent all connections from outside with the exception of [[SSH]] (port 22) which we leave open for service purposes (i.e.).&lt;br /&gt;
&lt;br /&gt;
=== System Preparation ===&lt;br /&gt;
&lt;br /&gt;
The following assumes that the gateway has two network interfaces:&lt;br /&gt;
* eth0 will be the external and&lt;br /&gt;
* eth1 the internal interface.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To use iptables you need to have at least the following kernel components compiled in or as modules&lt;br /&gt;
* &amp;lt;tt&amp;gt;ip_tables&lt;br /&gt;
* &amp;lt;tt&amp;gt;ip_conntrack&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;ip_conntrack_ftp&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
IP forwarding needs to be active (&amp;lt;tt&amp;gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&amp;lt;/userdefined&amp;lt;/tt&amp;gt;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup the external interface using the necessary data from your provider (IP and standard gateway). The internal interface (eth1) needs to get a private IP address, like 192.168.0.1. The routing table of the gateway will be set up automatically during network initialization.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Every LAN PC will use the NAT-Gateways internal IP (192.168.0.1 in our example) as standard gateway in its networking setup.&lt;br /&gt;
&lt;br /&gt;
=== Firewall Script ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;!/bin/sh&lt;br /&gt;
&lt;br /&gt;
ipt=/sbin/iptables&amp;lt;br&amp;gt;&lt;br /&gt;
extip=YOUREXTERNALIP  &amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; replace with your EXTERNAL IP&amp;lt;br&amp;gt;&lt;br /&gt;
lan=192.168.0.0/24  &amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; your LAN&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; start firewall&amp;lt;br&amp;gt;&lt;br /&gt;
start_firwall {&lt;br /&gt;
  echo &amp;quot;Enabling IP forwarding.&amp;quot;&lt;br /&gt;
  echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
&lt;br /&gt;
  echo &amp;quot;Enabling iptables firewall.&amp;quot;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; default policies&lt;br /&gt;
  $ipt -P INPUT DROP&lt;br /&gt;
  $ipt -P FORWARD DROP&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; NAT&lt;br /&gt;
  $ipt -t nat -A POSTROUTING -o eth0 -j SNAT --to-source $extip&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; INPUT chain&lt;br /&gt;
  $ipt -A INPUT -i lo -j ACCEPT&lt;br /&gt;
  $ipt -A INPUT -i eth1 -s $lan -j ACCEPT&lt;br /&gt;
  $ipt -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
  $ipt -A INPUT -p tcp --destination-port 22 -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; FORWARD chain&lt;br /&gt;
  $ipt -A FORWARD -i eth1 -s $lan -j ACCEPT&lt;br /&gt;
  $ipt -A FORWARD -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; stop firewall&amp;lt;br&amp;gt;&lt;br /&gt;
stop_firwall {&lt;br /&gt;
  $ipt -P INPUT DROP&lt;br /&gt;
  $ipt -P OUTPUT DROP&lt;br /&gt;
  $ipt -P FORWARD DROP&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; allow internal traffic&lt;br /&gt;
  $ipt -A INPUT -i eth1 -j ACCEPT&lt;br /&gt;
  $ipt -A OUTPUT -o eth1 -j ACCEPT&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; flushing, removing and zeroing tables&amp;lt;br&amp;gt;&lt;br /&gt;
reset_firwall {&lt;br /&gt;
  chains=`cat /proc/net/ip_tables_names`&lt;br /&gt;
  for i in $chains; do&lt;br /&gt;
    $debug $ipt -t $i -F&lt;br /&gt;
    $debug $ipt -t $i -X&lt;br /&gt;
    $debug $ipt -t $i -Z&lt;br /&gt;
  done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$1&amp;quot; in&lt;br /&gt;
  start|restart|reload)&lt;br /&gt;
    reset_firewall&lt;br /&gt;
    start_firewall&lt;br /&gt;
    ;;&lt;br /&gt;
  stop)&lt;br /&gt;
    reset_firewall&lt;br /&gt;
    stop_firewall&lt;br /&gt;
    ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Usage: $0 {start|stop|restart|reload}&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
    ;;&lt;br /&gt;
esac&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Explanation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This option enables forwarding of packets between network interfaces.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Every packet that will not be accepted by one of the rules in the INPUT or FORWARD chain will hit the default policy in the particular chain so we set every default policy to DROP.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;$ipt -t nat -A POSTROUTING -o eth0 -j SNAT --to-source $extip&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
With only one external IP you need to masquerade every outgoing packet using the external IP. This is done in the Postrouting Chain, just before the packet leaves the gateway. This works only with a static IP. If the external IP is assigned dynamically you should use the following line (replace the interface as apropriate):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The iptables INPUT chain allows all traffic from the loopback (lo) and internal interface (eth1). Outside connections (eth0) are accepted if they are already established, related to another connection or if it is a [[SSH]] connection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
New in comparison to the [[A_basic_firewall_configuration_suitable_for_a_workstation| workstation firewall]] is the FORWARD chain. This chain will handel all traffic that is destined for one of the LAN internal PCs. Like in the INPUT chain it allows all traffic from the internal interface (eth1) and only established or related connections from the outside interface (eth0).&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
&lt;br /&gt;
The firewalling script must be executable (&amp;lt;tt&amp;gt;[[chmod]] +x fwscript&amp;lt;/tt&amp;gt;). Now you can run it simply by typing: &amp;lt;tt&amp;gt;./fwscript [start|stop]&amp;lt;/tt&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Starting the script during system initialization depends on your distribution. You should check the system init scripts (&amp;lt;tt&amp;gt;/etc/init.d&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/etc/rc*.d&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Debian====&lt;br /&gt;
Copy the &amp;lt;tt&amp;gt;fwscript&amp;lt;/tt&amp;gt; file to &amp;lt;tt&amp;gt;/etc/init.d&amp;lt;/tt&amp;gt;.  Decide in which runlevels you want it to be started.  Now in each runlevel's &amp;lt;tt&amp;gt;/etc/rc*.d&amp;lt;/tt&amp;gt; directory, create an symlink called ''either'' &amp;lt;tt&amp;gt;S99fwscript&amp;lt;/tt&amp;gt; if you want the firewall ''on'', or &amp;lt;tt&amp;gt;K99fwscript&amp;lt;/tt&amp;gt; if you want it off, pointing to &amp;lt;tt&amp;gt;../init.d/fwscript&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
:&amp;lt;tt&amp;gt;ln -s /etc/init.d/fwscript /etc/rc2.d/K99fwscript&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;ln -s /etc/init.d/fwscript /etc/rc3.d/S99fwscript&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;start&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;stop&amp;lt;/tt&amp;gt; parameter will be automagically added according to whether the symlink started with S (for start) or K (for kill), ''except in runlevels 0 and 6 where ''everything'' will be stopped''.&lt;br /&gt;
&lt;br /&gt;
Alternatively, if you want your firewall active in '''all''' runlevels, put just one symlink in &amp;lt;tt&amp;gt;/etc/rcS.d&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Additional Information ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.netfilter.org/index.html Netfilter Homepage]&lt;br /&gt;
* [http://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO.html Packet Filtering HowTo]&lt;br /&gt;
* [http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.html NAT-HowTo]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=2993</id>
		<title>Bash tips</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=2993"/>
		<updated>2004-03-07T12:56:12Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==== Get your IP address====&lt;br /&gt;
&lt;br /&gt;
A [[bash]] example to get your IP address using http://www.whatismyip.com:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;B&amp;gt;lynx -dump http://www.whatismyip.com | awk '/^Your IP is/ { print $4; }' &amp;lt;/B&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or use this:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;/sbin/ifconfig ppp0 | awk '/inet/{ printf(&amp;quot;%s\n&amp;quot;, substr($2,index($2,&amp;quot;:&amp;quot;)+1)) }'&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Note that ppp0 stands for the first point-to-point-protocol device which is usually a modem. If you are using an ethernet adapter instead, replace ppp0 with eth0. You can also leave it out all together to list all the addresses associated with your computer.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Some counting examples====&lt;br /&gt;
x=0; x=$(expr $x + 1)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; x=$(echo $x + 1|bc)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; let x=$x+1&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; ((x++))&amp;lt;br /&amp;gt;&lt;br /&gt;
for (( x=0; x&amp;lt;10; x++ )) ; do echo $x ; done&lt;br /&gt;
&amp;lt;p /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Combining multiple conditions of if statements====&lt;br /&gt;
AND:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(a==1 &amp;amp;&amp;amp; b==2)&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
OR:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(( a==1|2|3 ))&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Renaming a set of files====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;for f in oldname* ; do mv $f ${f/oldname/newname} ; done&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Extracting addresses from a mailbox file====&lt;br /&gt;
This statement will pull out everything that looks like an e-mail address from a mailbox file  (here called ''foo''), and sort them into alphabetical order.  Note, it should be typed all on one line.&lt;br /&gt;
:&amp;lt;tt&amp;gt;awk '!/essage-[iI][dD]/ &amp;amp;amp;&amp;amp;amp; !/MAILER-DAEMON/ &amp;amp;amp;&amp;amp;amp; match ($0, /([A-Za-z][A-Za-z0-9._-]*@[A-Za-z0-9._-]*)/) {print substr($0, RSTART, RLENGTH)}' ''foo'' |sort |uniq&amp;lt;/tt&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; script works as follows.  If the line is not a message-id header, does not mention &amp;quot;MAILER-DAEMON&amp;quot;, and has something in it that looks like an email address, then the address-like portion is extracted and printed.  The output from &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; is sorted alphabetically by the &amp;lt;tt&amp;gt;sort&amp;lt;/tt&amp;gt; statement, and the &amp;lt;tt&amp;gt;uniq&amp;lt;/tt&amp;gt; statement deletes repetitions.  You probably will want to divert the output to another file; if the name of this file is ''bar'' then simply add &amp;lt;tt&amp;gt;&amp;amp;gt;''bar''&amp;lt;/tt&amp;gt; to the end of the above.  But it wouldn't hurt to check that the statement works before you commit it to a file.  You can run it once, displaying everything on the screen, amd scroll back with your mouse wheel to check the output. if it looks OK, you just need to press cursor up  (which will recover the previous line for editing and position the cursor at the end of the line),  and then type the extra more-than sign and filename.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Converting several wav files to mp3====&lt;br /&gt;
This statement will convert all .wav files in a directory to mp3  (assuming you already have the [[http://lame.sourceforge.net/ lame]] package installed):&lt;br /&gt;
:&amp;lt;tt&amp;gt;for i in *wav; do lame -h $i &amp;amp;amp;&amp;amp;amp;rm $i; done&amp;lt;/tt&amp;gt;&lt;br /&gt;
The double ampersand prevents rm from deleting files that weren't successfully converted.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Resolving a link====&lt;br /&gt;
This little script follows symbolic links wherever they may lead and prints the ultimate filename (if it exists!)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
# prints the real file pointed to by a link&lt;br /&gt;
# usage: $0 link&lt;br /&gt;
&lt;br /&gt;
ORIG_LINK=&amp;quot;$1&amp;quot;&lt;br /&gt;
LINK=`fqn &amp;quot;$1&amp;quot;`&lt;br /&gt;
while [ -h &amp;quot;$LINK&amp;quot; ]; do&lt;br /&gt;
	DIR=`dirname &amp;quot;$LINK&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
	# next link is everything from &amp;quot;-&amp;gt; &amp;quot;&lt;br /&gt;
	LINK=`ls -l &amp;quot;$LINK&amp;quot; |sed &amp;quot;s/^.*-&amp;gt; //&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
	LINK=`cd &amp;quot;$DIR&amp;quot;; fqn &amp;quot;$LINK&amp;quot;`&lt;br /&gt;
	if [ ! -e &amp;quot;$LINK&amp;quot; ]; then&lt;br /&gt;
		echo &amp;quot;\&amp;quot;$ORIG_LINK\&amp;quot; is a broken link: \&amp;quot;$LINK\&amp;quot; does not exist&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
		exit 1&lt;br /&gt;
	fi&lt;br /&gt;
done&lt;br /&gt;
echo &amp;quot;$LINK&amp;quot;&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Finding the 50 largest directories====&lt;br /&gt;
&lt;br /&gt;
du -S / | sort -nr | head -n50&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Auto-generating a shebang line====&lt;br /&gt;
:&amp;lt;tt&amp;gt;(echo -en &amp;quot;\x23\x21&amp;quot;; which perl; tail -n+2 foo) &amp;gt; bar&amp;lt;/tt&amp;gt;&lt;br /&gt;
This will print &amp;quot;#!&amp;quot; (the slightly weird syntax is needed to prevent the shell from interpreting the special characters itself) and the path to &amp;lt;tt&amp;gt;perl&amp;lt;/tt&amp;gt;, then everything except the first line (the original shebang) of the file &amp;lt;tt&amp;gt;foo&amp;lt;/tt&amp;gt;; and redirect all that to go into a file &amp;lt;tt&amp;gt;bar&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This is really meant for use in install scripts; obviously you know where perl is on your system, but not necessarily on anybody else's system  (though &amp;lt;tt&amp;gt;/usr/bin/perl&amp;lt;/tt&amp;gt; is a safe guess).  But you know bash is always at &amp;lt;tt&amp;gt;/bin/sh&amp;lt;/tt&amp;gt;.  So, instead of just saying in the documentation &amp;quot;change the first line .....&amp;quot;, you can write a little shell script that puts the correct shebang line in the file and copies it to &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt;.  Then, put this script in a .tar.gz file with your perl script and any documentation.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Set_up_NTL&amp;diff=4912</id>
		<title>Set up NTL</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Set_up_NTL&amp;diff=4912"/>
		<updated>2004-03-07T12:31:18Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Setting up NTL:home broadband==&lt;br /&gt;
The cable TV company NTL provides a broadband internet service through TV cables.  This article explains how to configure a Linux box to access this service.&lt;br /&gt;
&lt;br /&gt;
===Important===&lt;br /&gt;
NTL:home claim not to support Linux or Intranets.  They will '''not''' penalise you if you are running Linux or connecting up an Intranet, but they won't be able to give you technical support.  In fact, NTL:home's technical support seems to be limited to saying &amp;quot;switch off the set top box at the wall, wait half a minute, switch it back on again, and if it still doesn't work try re-installing Windows.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Preliminaries===&lt;br /&gt;
The NTL:home receiver has an RJ45 port on the back panel which can be connected to a standard network card.  IP addresses are allocated by DHCP, but the lease seems to be fairly long-term  (in the author's experience, only one change in nearly two years' use, and this was due to a power failure; my configuration is set to renew the lease every 3 hours.  I have actually pointed a domain at my address.  I would not recommend specifying an NTL allocated address as a mail exchanger, though; stick to fetchmail.)&lt;br /&gt;
&lt;br /&gt;
===Brokennesses with NTL:home===&lt;br /&gt;
The service is tied to the MAC address of the ethernet card plugged into the set top box.  NTL:home web space does not have any kind of scripting support.  NTL:home does not provide virtually-hosted e-mail.  This means you will need to get an account with a real ISP if you want to do more than look at other people's web sites and delete spam from your inbox.  I recommend [[http://www.uklinux.net/ UKLinux]] -- you get true virtual hosting, perl '''and''' PHP, MySQL or postgreSQL, procmail, SpamAssassin, an Envelope-To: header, and their fees are very reasonable.  You can still use the broken NTL:home web space to store photos, soundbites or something that can be downloaded verbatim.&lt;br /&gt;
&lt;br /&gt;
===DHCP===&lt;br /&gt;
There are several DHCP clients available, and your distribution may already include one.  In the author's experience, &amp;lt;tt&amp;gt;pump&amp;lt;/tt&amp;gt; does not work for anything past the initial provisioning stage; &amp;lt;tt&amp;gt;dhcpcd&amp;lt;/tt&amp;gt; works fine.&lt;br /&gt;
&lt;br /&gt;
Configure your chosen DHCP client, cross your fingers and plug your network cable into your set top box.  If all goes well, when you type &amp;lt;tt&amp;gt;/ifconfig&amp;lt;/tt&amp;gt;  you should see that you have a 10.x.x.x IP address bound to the network card.  &lt;br /&gt;
&lt;br /&gt;
===Provisioning===&lt;br /&gt;
When you first connect to the network, you need to go to a provisioning server to register yourself using the details in your welcome letter  (the Windows installation CD does this for you).  You will have to call the helpline to obtain the IP addresses of the provisioning servers, which will be unroutable addresses starting with 10; and  (unless you have a working BIND)  the nameservers, which will be real, routable addresses.  It's a bit of an unusual request, and you'll probably be kept waiting to speak to some arch-wizard; just stay calm and try not to think about the fact that you are paying these people's wages  (after all, they clearly don't).&lt;br /&gt;
&lt;br /&gt;
Once you have an address for a provisioning server, connect to it using a web browser and fill in the form.  A text-based browser should work fine for this.&lt;br /&gt;
&lt;br /&gt;
===After Provisioning===&lt;br /&gt;
If you were using Windows, you would have to restart your computer about now, because the far-end DHCP server has a new IP address for you.  But all you probably need to do is send a SIGHUP to your DHCP client, in order to make it check for a new IP address; and edit &amp;lt;tt&amp;gt;/etc/resolv.conf&amp;lt;/tt&amp;gt; to install the nameserver addresses.  You should now be good to go, with a routable IP address, and you should be able to &amp;lt;tt&amp;gt;ping&amp;lt;/tt&amp;gt; boxes.&lt;br /&gt;
&lt;br /&gt;
===Sharing a Connection===&lt;br /&gt;
It is possible to share a connection.  You will need two ethernet cards, one for the Internet (broadband) and one for the Intranet (LAN).  Just set it up as you would any NAT firewall/router.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Set_up_NTL&amp;diff=2752</id>
		<title>Set up NTL</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Set_up_NTL&amp;diff=2752"/>
		<updated>2004-03-07T12:21:16Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Setting up NTL:home broadband==&lt;br /&gt;
The cable TV company NTL provides a broadband internet service through TV cables.  This article explains how to configure a Linux box to access this service.&lt;br /&gt;
&lt;br /&gt;
===Important===&lt;br /&gt;
NTL:home claim not to support Linux or Intranets.  They will '''not''' penalise you if you are running Linux or connecting up an Intranet, but they won't be able to give you technical support.  In fact, NTL:home's technical support seems to be limited to saying &amp;quot;switch off the set top box at the wall, wait half a minute, switch it back on again, and if it still doesn't work try re-installing Windows.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Preliminaries===&lt;br /&gt;
The NTL:home receiver has an RJ45 port on the back panel which can be connected to a standard network card.  IP addresses are allocated by DHCP, but the lease seems to be fairly long-term  (in the author's experience, only one change in nearly two years' use, and this was due to a power failure; my configuration is set to renew the lease every 3 hours.  I have actually pointed a domain at my address.  I would not recommend specifying an NTL allocated address as a mail exchanger, though; stick to fetchmail.)&lt;br /&gt;
&lt;br /&gt;
===Brokennesses with NTL:home===&lt;br /&gt;
The service is tied to the MAC address of the ethernet card plugged into the set top box.  NTL:home web space does not have any kind of scripting support.  NTL:home does not provide virtually-hosted e-mail.  This means you will need to get an account with a real ISP if you want to do more than look at other people's web sites and delete spam from your inbox.  I recommend [[http://www.uklinux.net/|UKLinux]] -- you get true virtual hosting, perl '''and''' PHP, MySQL or postgreSQL, procmail, SpamAssassin, an Envelope-To: header, and their fees are very reasonable.  You can still use the broken NTL:home web space to store photos, soundbites or something that can be downloaded verbatim.&lt;br /&gt;
&lt;br /&gt;
===DHCP===&lt;br /&gt;
There are several DHCP clients available, and your distribution may already include one.  In the author's experience, &amp;lt;tt&amp;gt;pump&amp;lt;/tt&amp;gt; does not work for anything past the initial provisioning stage; &amp;lt;tt&amp;gt;dhcpcd&amp;lt;/tt&amp;gt; works fine.&lt;br /&gt;
&lt;br /&gt;
Configure your chosen DHCP client, cross your fingers and plug your network cable into your set top box.  If all goes well, when you type &amp;lt;tt&amp;gt;/ifconfig&amp;lt;/tt&amp;gt;  you should see that you have a 10.x.x.x IP address bound to the network card.  &lt;br /&gt;
&lt;br /&gt;
===Provisioning===&lt;br /&gt;
When you first connect to the network, you need to go to a provisioning server to register yourself using the details in your welcome letter  (the Windows installation CD does this for you).  You will have to call the helpline to obtain the IP addresses of the provisioning servers, which will be unroutable addresses starting with 10; and  (unless you have a working BIND)  the nameservers, which will be real, routable addresses.  It's a bit of an unusual request, and you'll probably be kept waiting to speak to some arch-wizard; just stay calm and try not to think about the fact that you are paying these people's wages  (after all, they clearly don't).&lt;br /&gt;
&lt;br /&gt;
Once you have an address for a provisioning server, connect to it using a web browser and fill in the form.  A text-based browser should work fine for this.&lt;br /&gt;
&lt;br /&gt;
===After Provisioning===&lt;br /&gt;
If you were using Windows, you would have to restart your computer about now, because the far-end DHCP server has a new IP address for you.  But all you probably need to do is send a SIGHUP to your DHCP client, in order to make it check for a new IP address; and edit &amp;lt;tt&amp;gt;/etc/resolv.conf&amp;lt;/tt&amp;gt; to install the nameserver addresses.  You should now be good to go, with a routable IP address, and you should be able to &amp;lt;tt&amp;gt;ping&amp;lt;/tt&amp;gt; boxes.&lt;br /&gt;
&lt;br /&gt;
===Sharing a Connection===&lt;br /&gt;
It is possible to share a connection.  You will need two ethernet cards, one for the Internet (broadband) and one for the Intranet (LAN).  Just set it up as you would any NAT firewall/router.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Networking&amp;diff=3464</id>
		<title>Networking</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Networking&amp;diff=3464"/>
		<updated>2004-03-07T11:20:23Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Networking computers is often easier than people think.  This section is dedicated to helping with basic network and network application setup.&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;i&amp;gt;Please refrain from just copy-pasting HOWTOS or reference documentation. But if you do that anyway, please apply formatting or your pasted text will look horribly broken!&amp;lt;/i&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Networking basics]] - Setting up your first network can be tricky. Here are some tips that can help.&lt;br /&gt;
**[[Network Addressing]]&lt;br /&gt;
**[[Set up modem|Setting up your modem]]&lt;br /&gt;
**[[Set up DSL|Setting up broadband]]&lt;br /&gt;
***[[Set up PPoE|Setting up broadband using PPoE]]&lt;br /&gt;
***[[Set up PPTP|Setting up broadband using PPTP]]&lt;br /&gt;
***[[Set up NTL|Specifics for NTL:home]] &lt;br /&gt;
* [[Advanced Networking]] - Networking for the more adventurous.&lt;br /&gt;
* [[Wireless networking]] - Setting up your linux box to access a wireless network.&lt;br /&gt;
* [[Web server]]s - Looking to set up a webserver?  Take a look here.&lt;br /&gt;
* [[Samba]] - Information on sharing files and printers between linux and Windows machines.&lt;br /&gt;
* [[Remote Desktop Connection]] - Connect to other computers with vnc, ssh, telnet.&lt;br /&gt;
* [[Netatalk]] - Information on sharing files and printers between linux and Macintosh machines.&lt;br /&gt;
* [[Mail services]]&lt;br /&gt;
** [[SMTP services]]&lt;br /&gt;
** [[POP3 services]]&lt;br /&gt;
** [[IMAP services]]&lt;br /&gt;
* [[The Domain Name System (DNS)]]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Php_tips&amp;diff=2740</id>
		<title>Php tips</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Php_tips&amp;diff=2740"/>
		<updated>2004-03-07T00:57:56Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: changed 'home' to 'page' to keep var name consistent&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==PHP TIPS==&lt;br /&gt;
[[PHP]] Hypertext Preprocessor is a great tool for making dynamic websites. Outside this Wiki, countless tips can be found in the comments section of the [http://www.php.net/manual/en/ official php manual] in the reference pages for each function. Here's a few little PHP tips and tricks.&lt;br /&gt;
&lt;br /&gt;
=== Making your first cut'n paste script work ===&lt;br /&gt;
The first thing people usually do when the experiment with php, is that they get a piece of php script from the web and try to use it. So here's how to make that first piece of code to work:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Change the [[file permissions]] so that your [[webserver]] can use it.&lt;br /&gt;
* Make sure that the php-code starts with ''&amp;lt;?php'', because sometimes just the basic ''&amp;lt;?'' doesn't work (or at least in my configuration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Creating larger pages with $variables ===&lt;br /&gt;
The first few pages work well by just by putting the code where you needed in the HTML-page. However,when your scripts grow bigger, it gets messy when you mix php and html.&lt;br /&gt;
I my opinion, the easiest way is to put the PHP-code code at the beginning of the file and the HTML in the end. &lt;br /&gt;
&lt;br /&gt;
The data that your great script has generated should be placed in string-type variables. For example: ''$pagetop'', ''$list'', ''$pageend'' and ''$menu''. &lt;br /&gt;
So now you can put all the generated data to those variables and use them in the HTML-part of you file by just putting ''&amp;lt;?php echo $pagetop; ?&amp;gt;'' in the according place.&lt;br /&gt;
&lt;br /&gt;
By doing this you can easily edit the PHP-scipt and the HTML part of your page without mixing the two so badly that you don't understand anything the next week .&lt;br /&gt;
&lt;br /&gt;
===FANCY TABLES===&lt;br /&gt;
It is easy -- and it also looks really cool 8) -- to generate a table with alternating coloured rows from PHP.  What you have to do is&lt;br /&gt;
#Declare a CSS style class for each background colour.&lt;br /&gt;
#Create an array with the background colours in the order you want them to appear in the table.&lt;br /&gt;
#Place some code in the loop which generates the table, to set a background colour for each row while recirculating the array.&lt;br /&gt;
The following code snippets should make it clear.&lt;br /&gt;
====Defining CSS Classes  (outside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;.DARKBG   {background-color: #bbbbbb}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.MIDDLEBG {background-color: #cccccc}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.LIGHTBG  {background-color: #dddddd}&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Initialising the array  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;$backgrounds = array(&amp;quot;LIGHTBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;, &amp;quot;DARKBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;);&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Building up the table  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;foreach ($foo as $i =&amp;gt; $j) {&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;array_push($backgrounds, ($bg = array_shift($backgrounds));&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;echo &amp;quot;&amp;amp;lt;TR CLASS=\&amp;quot;$bg\&amp;quot;&amp;amp;gt;&amp;quot;;&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;TD&amp;amp;gt;$i&amp;amp;lt;/TD&amp;amp;gt;&amp;amp;lt;TD&amp;amp;gt;$j&amp;amp;lt;/TD&amp;amp;gt;&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;/TR&amp;amp;gt;\n&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;};&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Explanation====&lt;br /&gt;
Each time around the loop  (here I've used a &amp;lt;tt&amp;gt;foreach&amp;lt;/tt&amp;gt; but it could be any kind of loop), the &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; (in the innermost brackets, so it gets evaluated first) causes a variable $bg to be set to the first element in $backgrounds and the others to be shifted down a place.  Then, this is pushed onto the tail end of the shortened array by the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt;.  So the whole array just gets recirculated, each time a value is read from the beginning it is moved to the end.  As the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; functions do not care about the length of the array, you could go through a whole rainbow of colours, or you could just alternate white and coloured rows.&lt;br /&gt;
&lt;br /&gt;
Note that if you want to use more than one table in your page, and you want them all to start on the same colour, you will have to re-create the array between finishing one table and starting the next.  This is because the array actually gets altered each time we go around the loop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Configuration Tricks and Traps===&lt;br /&gt;
&lt;br /&gt;
Here are some common pitfalls or trickies.&lt;br /&gt;
&lt;br /&gt;
====The &amp;lt;tt&amp;gt;register_globals&amp;lt;/tt&amp;gt; flag (a php.ini config option)====&lt;br /&gt;
&lt;br /&gt;
If set to true, all GET, POST, FILE, and COOKIE variables will be registered as global variables. That is, if you called the url &amp;lt;tt&amp;gt;index.php?page=home&amp;lt;/tt&amp;gt; the script would have the variable &amp;lt;tt&amp;gt;$page&amp;lt;/tt&amp;gt; available, with the value 'home'. However, with register_globals off (the way it should really be, for security) &amp;lt;tt&amp;gt;$page&amp;lt;/tt&amp;gt; would not be available. Instead, you would use &amp;lt;tt&amp;gt;$_GET['page']&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;$HTTP_GET_VARS['page']&amp;lt;/tt&amp;gt; (the first for any version of php beyond about 4.1; the second for older versions).&lt;br /&gt;
&lt;br /&gt;
====The &amp;lt;tt&amp;gt;allow_short_open_tags&amp;lt;/tt&amp;gt; option====&lt;br /&gt;
&lt;br /&gt;
If set to true, &amp;lt;tt&amp;gt;&amp;lt;?&amp;lt;/tt&amp;gt; is a legitimate way of starting a php block. This also means that you can use the short echo syntax: &amp;lt;tt&amp;gt;&amp;lt;?=$var ?&amp;gt;&amp;lt;/tt&amp;gt; will output the value of $var.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the shorts tags are a bad idea if:&lt;br /&gt;
* You are mixing scripting languages. Different languages use different tags, but often use the &amp;lt;? prefix.&lt;br /&gt;
* You have xml content. PHP will choke on the &amp;lt;?xml declaration if you are allowing the short tags; it reads it as a php command &amp;quot;xml&amp;quot;, which of course doesn't work, so spews a parse error.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=USB_Card_Readers&amp;diff=5626</id>
		<title>USB Card Readers</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=USB_Card_Readers&amp;diff=5626"/>
		<updated>2004-03-07T00:53:43Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==USB Card Readers==&lt;br /&gt;
USB card readers are commonly available.  They generally consist of a unit about the size of a Walkman cassette with several slots for different kinds of memory cards and an LED which flashes to indicate when data is being read or written.  Internal card readers are also available, which fit into a 3.5in drive bay and connect to the front USB header on the motherboard, but if you already have USB pprts on your front panel you will lose the use of them.&lt;br /&gt;
&lt;br /&gt;
Such readers are invariably supplied with a driver CD for Windows and Macs, giving the impression that they are not usable with Linux.  In fact, this is not at all the case.  The Linux kernel has included USB support ever since version 2.4, and the USB drivers have been back-ported to Linux 2.2.  Devices such as memory card readers, disc/flash drives and digital cameras are all treated as mass storage devices and use a common protocol which emulates a SCSI disc device.&lt;br /&gt;
&lt;br /&gt;
If you are using a stock kernel you will almost certainly have the necessary modules compiled.  I will assume for now that if you know enough to compile your own kernel, then you will be able to sort out any problems with missing modules.&lt;br /&gt;
&lt;br /&gt;
Begin by opening an Xterm or console and becoming root.  Yes, being root all the time is bad and so forth; but you genuinely need it this time because you are going to play about with hardware devices.  Once you have successfully mounted your reader, you can set it up so that ordinary users can mount it.&lt;br /&gt;
&lt;br /&gt;
Type&lt;br /&gt;
:&amp;lt;tt&amp;gt;ls /dev/sd*&amp;lt;/tt&amp;gt;&lt;br /&gt;
Make sure that some devices are listed  (they are devices, not files, so will be listed in yellow if you have set up coloured directory listings).  For each drive letter such as &amp;lt;tt&amp;gt;sda&amp;lt;/tt&amp;gt;, there will also be several partitions &amp;lt;tt&amp;gt;sda1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sda2&amp;lt;/tt&amp;gt; and so on.&lt;br /&gt;
&lt;br /&gt;
Now plug in your reader and enter&lt;br /&gt;
:&amp;lt;tt&amp;gt;dmesg |less&amp;lt;/tt&amp;gt;&lt;br /&gt;
Look for lines that say something like&lt;br /&gt;
:&amp;lt;tt&amp;gt;Attached scsi removable disk sda at scsi1, channel 0, id 0, lun 0&amp;lt;/tt&amp;gt;&lt;br /&gt;
(there will be one for each slot, each with a different drive letter; for example, I see sda, sdb, sdc and sdd when using my four-slot reader).  If instead you get a message like&lt;br /&gt;
:&amp;lt;tt&amp;gt;USB device 2 is not claimed by any active driver&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you probably just need to load the relevant kernel module.  Enter&lt;br /&gt;
:&amp;lt;tt&amp;gt;modprobe usb-storage&amp;lt;/tt&amp;gt;&lt;br /&gt;
to load it now -- and then update &amp;lt;tt&amp;gt;/etc/modules&amp;lt;/tt&amp;gt; to force the module to be loaded the next time the computer boots.  Just add a line with &amp;lt;tt&amp;gt;usb-storage&amp;lt;/tt&amp;gt; on it.&lt;br /&gt;
&lt;br /&gt;
Make mount points for the memory cards you are going to use, for example &amp;lt;tt&amp;gt;/mnt/sd&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/mnt/smartmedia&amp;lt;/tt&amp;gt;.&lt;br /&gt;
:&amp;lt;tt&amp;gt;mkdir /mnt/sd&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;mkdir /mnt/smartmedia&amp;lt;/tt&amp;gt;&lt;br /&gt;
Insert a memory card.  Now begins a little trial-and-error; we know what the drive letters are from dmesg, but not which one is which.  The easiest way to find out is simply to try mounting drive letters one at a time, until we find the one with the files on the card -- then we know we have mounted it.&lt;br /&gt;
&lt;br /&gt;
Enter&lt;br /&gt;
:&amp;lt;tt&amp;gt;mount -tvfat -oro /dev/sda1 /mnt/sd&amp;lt;/tt&amp;gt;&lt;br /&gt;
(assuming it was an sd card you inserted).  This translates as:  mount a vfat  (= Windows 95)-type file system, read only, located on the &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt;st partition of the drive &amp;lt;tt&amp;gt;sda&amp;lt;/tt&amp;gt;, under &amp;lt;tt&amp;gt;/mnt/sd&amp;lt;/tt&amp;gt;.  (Specifying -tmsdos will appear to work, but it restricts filenames to 8+3 characters and may cause problems.)&lt;br /&gt;
&lt;br /&gt;
If the mount operation is successful, then congratulations - you have found that &amp;lt;tt&amp;gt;sda&amp;lt;/tt&amp;gt; is the sd slot!  Try listing the files with &amp;lt;tt&amp;gt;ls /mnt/sd/&amp;lt;/tt&amp;gt;.  If the mount fails, you will get an error message; just try the next drive letter until you find the right one.&lt;br /&gt;
&lt;br /&gt;
Once you have successfully mounted the memory card, you need to unmount it before you can remove the card.  So enter&lt;br /&gt;
:&amp;lt;tt&amp;gt;umount /mnt/sd&amp;lt;/tt&amp;gt;&lt;br /&gt;
Repeat the process for each type of memory card you have.&lt;br /&gt;
&lt;br /&gt;
Now you should have a list of which drive letter relates to which card slot.  All that remains to do is create an entry in &amp;lt;tt&amp;gt;/etc/fstab&amp;lt;/tt&amp;gt; to allow any ordinary user to mount them.  For example, with my reader, the SmartMedia slot is &amp;lt;tt&amp;gt;sdc&amp;lt;/tt&amp;gt; and the SD card slot is &amp;lt;tt&amp;gt;sdd&amp;lt;/tt&amp;gt;, so I added these lines to my fstab:&lt;br /&gt;
:&amp;lt;tt&amp;gt;/dev/sdc1 /mnt/smartmedia vfat user,noauto,noexec,umask=022&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;/dev/sdd1 /mnt/sd vfat user,noauto,noexec,umask=022&amp;lt;/tt&amp;gt;&lt;br /&gt;
The fields on the line can be separated by spaces or tabs.  The first column is the device or partition to be mounted.  The second column is the target mountpoint.  The third column is the file system type, and the fourth is a comma-separated string of options.  &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt; allows any user to mount the device.  &amp;lt;tt&amp;gt;noauto&amp;lt;/tt&amp;gt; prevents automatic mounting at boot time, in case there is no card in the slot.  &amp;lt;tt&amp;gt;noexec&amp;lt;/tt&amp;gt; means don't allow files beneath the mountpoint to be executed, and &amp;lt;tt&amp;gt;umask=022&amp;lt;/tt&amp;gt; sets the default file permissions to exclude group and world write.&lt;br /&gt;
&lt;br /&gt;
Once &amp;lt;tt&amp;gt;/etc/fstab&amp;lt;/tt&amp;gt; is modified, any user should be able to mount a card slot with a command such as&lt;br /&gt;
:&amp;lt;tt&amp;gt;mount /mnt/smartmedia&amp;lt;/tt&amp;gt;&lt;br /&gt;
This shorthand form looks up all the missing information from &amp;lt;tt&amp;gt;/etc/fstab&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When you are done with the card reader, be sure to unmount it before you remove the card, with the command.&lt;br /&gt;
:&amp;lt;tt&amp;gt;umount /mnt/smartmedia&amp;lt;/tt&amp;gt;&lt;br /&gt;
Wait for the light to stop flashing before you remove the card.  If you have written many files, this may take ages, but it is perfectly normal; Linux normally caches all disk writes in spare RAM, and only commits the changes when it has to:  usually when the device is unmounted, the &amp;lt;tt&amp;gt;sync&amp;lt;/tt&amp;gt; command is issued or the memory is required by another process.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=USB&amp;diff=5018</id>
		<title>USB</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=USB&amp;diff=5018"/>
		<updated>2004-03-06T23:35:00Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;USB (Universal Serial Bus) is a protocol used by hardware devices like [[Disk Drives|disk drives]] and [[Scanners|scanners]] to communicate with your computer.&lt;br /&gt;
&lt;br /&gt;
The [[Linux]] [[Kernel|kernel]] uses [[drivers]] to communicate with the [[hardware]] but to the user this should all be transparent. With most modern [[Distributions|distributions]] USB devices are well supported. If you plug in a usb memory stick it will automatically appear as a folder or a removable drive on your desktop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[USB Card Readers]]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Retrieving_mail_manually_using_telnet&amp;diff=6508</id>
		<title>Retrieving mail manually using telnet</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Retrieving_mail_manually_using_telnet&amp;diff=6508"/>
		<updated>2004-03-06T20:38:34Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Retrieving Mail Manually Using &amp;lt;tt&amp;gt;telnet&amp;lt;/tt&amp;gt;==&lt;br /&gt;
You can retrieve your e-mail manually using &amp;lt;tt&amp;gt;telnet&amp;lt;/tt&amp;gt;.  This might be handy in an emergency; for example, if you are away for a few days, your inbox fills up with a nasty mix of spam, viruses and virus bounces, and you only have a low-speed internet connection.  You can view just the headers of the messages and delete any that aren't worth downloading.  ''(Understanding message headers probably warrants an article in its own right - AJS)''  This information might also be useful if you need to write a custom e-mail client.&lt;br /&gt;
&lt;br /&gt;
Have handy your mail server address  (I'll use &amp;lt;tt&amp;gt;pop3.myisp.co.uk&amp;lt;/tt&amp;gt; for this example), and your pop3 login and password  (let's say &amp;lt;tt&amp;gt;fred&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;laRge1&amp;lt;/tt&amp;gt;.  Open an Xterm if needs be, and enter&lt;br /&gt;
:&amp;lt;tt&amp;gt;telnet pop3.myisp.co.uk 110&amp;lt;/tt&amp;gt;&lt;br /&gt;
(You can also use a GUI-based client.  If so, be sure to set the port number to 110, which is the port used for POP3 sessions.)  You should see some kind of prompt from the server, such as&lt;br /&gt;
:&amp;lt;tt&amp;gt;Connected to pop3.myisp.co.uk.&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;Escape character is '^]'.&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;+OK Qpopper (version 4.0.4) at pop3.myisp.co.uk starting. &amp;amp;lt;14859.1078603175@pop3.myisp.co.uk&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
POP3 is a human-readable protocol with machine-readable clues.  The client  (that's you, or more usually a mail client such as KMail)  gives commands to the server, and the server gives responses to the client.  A response beginning with a plus sign + is a &amp;quot;good&amp;quot; response  (the remainder of the line usually takes the form of a confirmation or prompt for the benefit of humans).  A response beginning with &amp;quot;-&amp;quot; is a &amp;quot;bad&amp;quot; response, and the rest of the text is usually a meaningful error message that can be saved in a logfile.  There are different POP3 server programmes, and they all have slightly different messages, so you may see something different when you try it, and of course your messages probably won't have the same lengths as in this example.&lt;br /&gt;
&lt;br /&gt;
Anyway, first of all you need to login, using the USER command.  Type&lt;br /&gt;
:&amp;lt;tt&amp;gt;USER fred&amp;lt;/tt&amp;gt;&lt;br /&gt;
and the server will issue a prompt for a password;&lt;br /&gt;
:&amp;lt;tt&amp;gt;+OK Password required for fred&amp;lt;/tt&amp;gt;&lt;br /&gt;
to which you should respond with the PASS command and your password;&lt;br /&gt;
:&amp;lt;tt&amp;gt;PASS laRge1&amp;lt;/tt&amp;gt;&lt;br /&gt;
If the password was correct, you should see a summary of your messages.&lt;br /&gt;
:&amp;lt;tt&amp;gt;+OK fred has 2 visible messages (0 hidden) in 9513 octets.&amp;lt;/tt&amp;gt;&lt;br /&gt;
(&amp;quot;octets&amp;quot; is just another word for &amp;quot;bytes&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
If you use the LIST command, you can see the length of each message;&lt;br /&gt;
:&amp;lt;tt&amp;gt;LIST&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;+OK 2 visible messages (9513 octets)&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;1 4863&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;2 4650&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full stop on a line by itself indicates the end of a multi-line response, but there should always be some clue in the first line as to how long the response is going to be.  For each message there is a line with its sequence number and length.&lt;br /&gt;
&lt;br /&gt;
To read just the first few lines of a message, use the TOP command.  This takes two parameters, a message number and a number of lines, and returns the full header of the message plus however many lines you asked for.  I have noticed that virus messages usually have the nasty attachment's filename visible within the first 20 lines, so type&lt;br /&gt;
:&amp;lt;tt&amp;gt;TOP 1 20&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the final full stop on the response, but the +OK line again should include the length.&lt;br /&gt;
&lt;br /&gt;
To see just the header and nothing from the body, use &amp;lt;tt&amp;gt;TOP 1 0&amp;lt;/tt&amp;gt;.&lt;br /&gt;
To view a message in its entirety, use the RETR (for retrieve) command;&lt;br /&gt;
:&amp;lt;tt&amp;gt;RETR 1&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To delete a message, use the DELE (for delete) command;&lt;br /&gt;
:&amp;lt;tt&amp;gt;DELE 1&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you are done, use the QUIT command;&lt;br /&gt;
:&amp;lt;tt&amp;gt;QUIT&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that most POP3 servers will time you out after a period of inactivity.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=POP3&amp;diff=2351</id>
		<title>POP3</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=POP3&amp;diff=2351"/>
		<updated>2004-03-06T19:54:01Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: added section 'retrieving mail with telnet'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Post Office Protocol 3== &lt;br /&gt;
&lt;br /&gt;
A protocol that provides a simple, standardized way for users to access mailboxes and download messages to their computers. One of the most used mail-protocols on the internet.&lt;br /&gt;
&lt;br /&gt;
'POP' stands for Post Office Protocol.  Currently, [[POP3]] (POP version 3) is the latest version.  POP is a protocol for receiving [[email]] from a remote [[host]] in a single [[batch]]; it is best suited for [[non-interactive]] mail retrieval, where [[email]] is finally stored on the client [[computer]].  It is currently the most wide-spread email-reading protocol, although [[IMAP]] has made strong headway.&lt;br /&gt;
&lt;br /&gt;
The POP3 protocol runs on [[TCP]] [[port]] 110.&lt;br /&gt;
&lt;br /&gt;
===POP3 daemons===&lt;br /&gt;
* [[Courier Mail Server]]&lt;br /&gt;
&lt;br /&gt;
===POP3 examples===&lt;br /&gt;
* [[Retrieving mail manually using telnet]]&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Php_tips&amp;diff=1649</id>
		<title>Php tips</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Php_tips&amp;diff=1649"/>
		<updated>2004-03-06T03:35:54Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: it's = esta, its = su&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==PHP TIPS==&lt;br /&gt;
[[PHP]] Hypertext parser is a great tool for making dynamic websites, but it has its own little tips and tricks. Here's a few.&lt;br /&gt;
&lt;br /&gt;
=== Making your first cut'n paste script work ===&lt;br /&gt;
The first thing people usually do when the experiment with php, is that they get a piece of php script from the web and try to use it. So here's how to make that first piece of code to work:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Change the [[file permissions]] so that your [[webserver]] can use it.&lt;br /&gt;
* Make sure that the php-code starts with ''&amp;lt;?php'', because sometimes just the basic ''&amp;lt;?'' doesn't work (or at least in my configuration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Creating larger pages with $variables ===&lt;br /&gt;
The first few pages work well by just by putting the code where you needed in the HTML-page, but when your scrips grow bigger, it gets messy when you have some php here and html there.&lt;br /&gt;
I my opinion, the easiest way is to put the PHP-code code at the beginning of the file and the HTML in the end. &lt;br /&gt;
&lt;br /&gt;
The data that your great script has generated should be placed in string-type variables. For example: ''$pagetop'', ''$list'', ''$pageend'' and ''$menu''. &lt;br /&gt;
So now you can put all the generated data to those variables and use them in the HTML-part of you file by just putting ''&amp;lt;?php echo $pagetop; ?&amp;gt;'' in the according place.&lt;br /&gt;
&lt;br /&gt;
By doing this you can easily edit the PHP-scipt and the HTML part of your page without mixing the two so badly that you don't understand anything the next week .&lt;br /&gt;
&lt;br /&gt;
===FANCY TABLES===&lt;br /&gt;
It is easy -- and it also looks really cool 8) -- to generate a table with alternating coloured rows from PHP.  What you have to do is&lt;br /&gt;
#Declare a CSS style class for each background colour.&lt;br /&gt;
#Create an array with the background colours in the order you want them to appear in the table.&lt;br /&gt;
#Place some code in the loop which generates the table, to set a background colour for each row while recirculating the array.&lt;br /&gt;
The following code snippets should make it clear.&lt;br /&gt;
====Defining CSS Classes  (outside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;.DARKBG   {background-color: #bbbbbb}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.MIDDLEBG {background-color: #cccccc}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.LIGHTBG  {background-color: #dddddd}&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Initialising the array  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;$backgrounds = array(&amp;quot;LIGHTBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;, &amp;quot;DARKBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;);&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Building up the table  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;foreach ($foo as $i =&amp;gt; $j) {&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;array_push($backgrounds, ($bg = array_shift($backgrounds));&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;echo &amp;quot;&amp;amp;lt;TR CLASS=\&amp;quot;$bg\&amp;quot;&amp;amp;gt;&amp;quot;;&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;TD&amp;amp;gt;$i&amp;amp;lt;/TD&amp;amp;gt;&amp;amp;lt;TD&amp;amp;gt;$j&amp;amp;lt;/TD&amp;amp;gt;&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;/TR&amp;amp;gt;\n&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;};&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Explanation====&lt;br /&gt;
Each time around the loop  (here I've used a &amp;lt;tt&amp;gt;foreach&amp;lt;/tt&amp;gt; but it could be any kind of loop), the &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; (in the innermost brackets, so it gets evaluated first) causes a variable $bg to be set to the first element in $backgrounds and the others to be shifted down a place.  Then, this is pushed onto the tail end of the shortened array by the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt;.  So the whole array just gets recirculated, each time a value is read from the beginning it is moved to the end.  As the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; functions do not care about the length of the array, you could go through a whole rainbow of colours, or you could just alternate white and coloured rows.&lt;br /&gt;
&lt;br /&gt;
Note that if you want to use more than one table in your page, and you want them all to start on the same colour, you will have to re-create the array between finishing one table and starting the next.  This is because the array actually gets altered each time we go around the loop.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=1810</id>
		<title>Bash tips</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=1810"/>
		<updated>2004-03-06T03:26:13Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A [[bash]] example to get your IP address using http://www.whatismyip.com:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;B&amp;gt;lynx -dump http://www.whatismyip.com | grep &amp;quot;Your IP is&amp;quot;&amp;lt;/B&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or use this:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;/sbin/ifconfig ppp0 | awk '/inet/{ printf(&amp;quot;%s\n&amp;quot;, substr($2,6)) }'&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Note that ppp0 stands for the first point-to-point-protocol device which is usually a modem. If you are using a network adapter instead, replace ppp0 with eth0.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Some counting examples:&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; x=$(expr $x + 1)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; x=$(echo $x + 1|bc)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; let x=$x+1&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; ((x++))&amp;lt;br /&amp;gt;&lt;br /&gt;
for (( x=0; x&amp;lt;10; x++ )) ; do echo $x ; done&lt;br /&gt;
&amp;lt;p /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Combining multiple conditions of if statements&amp;lt;br /&amp;gt;&lt;br /&gt;
AND:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(a==1 &amp;amp;&amp;amp; b==2)&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
OR:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(( a==1|2|3 ))&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Renaming a set of files====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;for f in oldname* ; do mv $f ${f/oldname/newname} ; done&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Extracting addresses from a mailbox file====&lt;br /&gt;
This statement will pull out everything that looks like an e-mail address from a mailbox file  (here called ''foo''), and sort them into alphabetical order.  Note, it should be typed all on one line.&lt;br /&gt;
:&amp;lt;tt&amp;gt;awk '!/essage-[iI][dD]/ &amp;amp;amp;&amp;amp;amp; !/MAILER-DAEMON/ &amp;amp;amp;&amp;amp;amp; match ($0, /([A-Za-z][A-Za-z0-9._-]*@[A-Za-z0-9._-]*)/) {print substr($0, RSTART, RLENGTH)}' ''foo'' |sort |uniq&amp;lt;/tt&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; script works as follows.  If the line is not a message-id header, does not mention &amp;quot;MAILER-DAEMON&amp;quot;, and has something in it that looks like an email address, then the address-like portion is extracted and printed.  The output from &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; is sorted alphabetically by the &amp;lt;tt&amp;gt;sort&amp;lt;/tt&amp;gt; statement, and the &amp;lt;tt&amp;gt;uniq&amp;lt;/tt&amp;gt; statement deletes repetitions.  You probably will want to divert the output to another file; if the name of this file is ''bar'' then simply add &amp;lt;tt&amp;gt;&amp;amp;gt;''bar''&amp;lt;/tt&amp;gt; to the end of the above.  But it wouldn't hurt to check that the statement works before you commit it to a file.  You can run it once, displaying everything on the screen, amd scroll back with your mouse wheel to check the output. if it looks OK, you just need to press cursor up  (which will recover the previous line for editing and position the cursor at the end of the line),  and then type the extra more-than sign and filename.&lt;br /&gt;
&lt;br /&gt;
====Converting several wav files to mp3====&lt;br /&gt;
This statement will convert all .wav files in a directory to mp3  (assuming you already have the [[http://lame.sourceforge.net/ lame]] package installed):&lt;br /&gt;
:&amp;lt;tt&amp;gt;for i in *wav; do lame -h $i &amp;amp;amp;&amp;amp;amp;rm $i; done&amp;lt;/tt&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=1596</id>
		<title>Bash tips</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=1596"/>
		<updated>2004-03-06T03:23:25Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A [[bash]] example to get your IP address using http://www.whatismyip.com:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;B&amp;gt;lynx -dump http://www.whatismyip.com | grep &amp;quot;Your IP is&amp;quot;&amp;lt;/B&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or use this:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;/sbin/ifconfig ppp0 | awk '/inet/{ printf(&amp;quot;%s\n&amp;quot;, substr($2,6)) }'&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Note that ppp0 stands for the first point-to-point-protocol device which is usually a modem. If you are using a network adapter instead, replace ppp0 with eth0.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Some counting examples:&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; x=$(expr $x + 1)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; x=$(echo $x + 1|bc)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; let x=$x+1&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; ((x++))&amp;lt;br /&amp;gt;&lt;br /&gt;
for (( x=0; x&amp;lt;10; x++ )) ; do echo $x ; done&lt;br /&gt;
&amp;lt;p /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Combining multiple conditions of if statements&amp;lt;br /&amp;gt;&lt;br /&gt;
AND:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(a==1 &amp;amp;&amp;amp; b==2)&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
OR:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(( a==1|2|3 ))&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Renaming a set of files====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;for f in oldname* ; do mv $f ${f/oldname/newname} ; done&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Extracting addresses from a mailbox file====&lt;br /&gt;
This statement will pull out everything that looks like an e-mail address from a mailbox file  (here called ''foo''), and sort them into alphabetical order.  Note, it should be typed all on one line.&lt;br /&gt;
:&amp;lt;tt&amp;gt;awk '!/essage-[iI][dD]/ &amp;amp;amp;&amp;amp;amp; !/MAILER-DAEMON/ &amp;amp;amp;&amp;amp;amp; match ($0, /([A-Za-z][A-Za-z0-9._-]*@[A-Za-z0-9._-]*)/) {print substr($0, RSTART, RLENGTH)}' ''foo'' |sort |uniq&amp;lt;/tt&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; script works as follows.  If the line is not a message-id header, does not mention &amp;quot;MAILER-DAEMON&amp;quot;, and has something in it that looks like an email address, then the address-like portion is extracted and printed.  The output from &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; is sorted alphabetically by the &amp;lt;tt&amp;gt;sort&amp;lt;/tt&amp;gt; statement, and the &amp;lt;tt&amp;gt;uniq&amp;lt;/tt&amp;gt; statement deletes repetitions.  You probably will want to divert the output to another file; if the name of this file is ''bar'' then simply add &amp;lt;tt&amp;gt;&amp;amp;gt;''bar''&amp;lt;/tt&amp;gt; to the end of the above.  But it wouldn't hurt to check that the statement works before you commit it to a file.  You can run it once, displaying everything on the screen, amd scroll back with your mouse wheel to check the output. if it looks OK, you just need to press cursor up  (which will recover the previous line for editing and position the cursor at the end of the line),  and then type the extra more-than sign and filename.&lt;br /&gt;
&lt;br /&gt;
====Converting several wav files to mp3====&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;tt&amp;gt;for i in *wav; do lame -h $i &amp;amp;amp;&amp;amp;amp;rm $i; done&amp;lt;/tt&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=1586</id>
		<title>Bash tips</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Bash_tips&amp;diff=1586"/>
		<updated>2004-03-06T03:21:05Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A [[bash]] example to get your IP address using http://www.whatismyip.com:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;B&amp;gt;lynx -dump http://www.whatismyip.com | grep &amp;quot;Your IP is&amp;quot;&amp;lt;/B&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or use this:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;/sbin/ifconfig ppp0 | awk '/inet/{ printf(&amp;quot;%s\n&amp;quot;, substr($2,6)) }'&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Note that ppp0 stands for the first point-to-point-protocol device which is usually a modem. If you are using a network adapter instead, replace ppp0 with eth0.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Some counting examples:&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; x=$(expr $x + 1)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; x=$(echo $x + 1|bc)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; let x=$x+1&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; ((x++))&amp;lt;br /&amp;gt;&lt;br /&gt;
for (( x=0; x&amp;lt;10; x++ )) ; do echo $x ; done&lt;br /&gt;
&amp;lt;p /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Combining multiple conditions of if statements&amp;lt;br /&amp;gt;&lt;br /&gt;
AND:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(a==1 &amp;amp;&amp;amp; b==2)&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
OR:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(( a==1|2|3 ))&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====Renaming a set of files====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;for f in oldname* ; do mv $f ${f/oldname/newname} ; done&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Extracting addresses from a mailbox file====&lt;br /&gt;
This statement will pull out everything that looks like an e-mail address from a mailbox file  (here called ''foo''), and sort them into alphabetical order.  Note, it should be typed all on one line.&lt;br /&gt;
:&amp;lt;tt&amp;gt;awk '!/essage-[iI][dD]/ &amp;amp;amp;&amp;amp;amp; !/MAILER-DAEMON/ &amp;amp;amp;&amp;amp;amp; match ($0, /([A-Za-z][A-Za-z0-9._-]*@[A-Za-z0-9._-]*)/) {print substr($0, RSTART, RLENGTH)}' ''foo'' |sort |uniq&amp;lt;/tt&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; script works as follows.  If the line is not a message-id header, does not mention &amp;quot;MAILER-DAEMON&amp;quot;, and has something in it that looks like an email address, then the address-like portion is extracted and printed.  The output from &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt; is sorted alphabetically by the &amp;lt;tt&amp;gt;sort&amp;lt;/tt&amp;gt; statement, and the &amp;lt;tt&amp;gt;uniq&amp;lt;/tt&amp;gt; statement deletes repetitions.  You probably will want to divert the output to another file; if the name of this file is ''bar'' then simply add &amp;lt;tt&amp;gt;&amp;amp;gt;''bar''&amp;lt;/tt&amp;gt; to the end of the above.  But it wouldn't hurt to check that the statement works before you commit it to a file.  You can run it once, displaying everything on the screen, amd scroll back with your mouse wheel to check the output. if it looks OK, you just need to press cursor up  (which will recover the previous line for editing and position the cursor at the end of the line),  and then type the extra more-than sign and filename.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=PHP&amp;diff=1529</id>
		<title>PHP</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=PHP&amp;diff=1529"/>
		<updated>2004-03-06T02:52:42Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==PHP TIPS==&lt;br /&gt;
&lt;br /&gt;
===FANCY TABLES===&lt;br /&gt;
It is easy -- and it also looks really cool 8) -- to generate a table with alternating coloured rows from PHP.  What you have to do is&lt;br /&gt;
#Declare a CSS style class for each background colour.&lt;br /&gt;
#Create an array with the background colours in the order you want them to appear in the table.&lt;br /&gt;
#Place some code in the loop which generates the table, to set a background colour for each row while recirculating the array.&lt;br /&gt;
The following code snippets should make it clear.&lt;br /&gt;
====Defining CSS Classes  (outside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;.DARKBG   {background-color: #bbbbbb}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.MIDDLEBG {background-color: #cccccc}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.LIGHTBG  {background-color: #dddddd}&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Initialising the array  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;$backgrounds = array(&amp;quot;LIGHTBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;, &amp;quot;DARKBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;);&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Building up the table  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;foreach ($foo as $i =&amp;gt; $j) {&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;array_push($backgrounds, ($bg = array_shift($backgrounds));&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;echo &amp;quot;&amp;amp;lt;TR CLASS=\&amp;quot;$bg\&amp;quot;&amp;amp;gt;&amp;quot;;&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;TD&amp;amp;gt;$i&amp;amp;lt;/TD&amp;amp;gt;&amp;amp;lt;TD&amp;amp;gt;$j&amp;amp;lt;/TD&amp;amp;gt;&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;/TR&amp;amp;gt;\n&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;};&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Explanation====&lt;br /&gt;
Each time around the loop  (here I've used a &amp;lt;tt&amp;gt;foreach&amp;lt;/tt&amp;gt; but it could be any kind of loop), the &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; (in the innermost brackets, so it gets evaluated first) causes a variable $bg to be set to the first element in $backgrounds and the others to be shifted down a place.  Then, this is pushed onto the tail end of the shortened array by the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt;.  So the whole array just gets recirculated, each time a value is read from the beginning it is moved to the end.  As the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; functions do not care about the length of the array, you could go through a whole rainbow of colours, or you could just alternate white and coloured rows.&lt;br /&gt;
&lt;br /&gt;
Note that if you want to use more than one table in your page, and you want them all to start on the same colour, you will have to re-create the array between finishing one table and starting the next.  This is because the array actually gets altered each time we go around the loop.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=PHP&amp;diff=1522</id>
		<title>PHP</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=PHP&amp;diff=1522"/>
		<updated>2004-03-06T02:50:14Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==PHP TIPS==&lt;br /&gt;
&lt;br /&gt;
===FANCY TABLES===&lt;br /&gt;
It is easy -- and it also looks really cool 8) -- to generate a table with alternating coloured rows from PHP.  What you have to do is&lt;br /&gt;
#Declare a CSS style class for each background colour.&lt;br /&gt;
#Create an array with the background colours in the order you want them to appear in the table.&lt;br /&gt;
#Place some code in the loop which generates the table, to set a background colour for each row.&lt;br /&gt;
&lt;br /&gt;
====Defining CSS Classes  (outside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;.DARKBG   {background-color: #bbbbbb}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.MIDDLEBG {background-color: #cccccc}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.LIGHTBG  {background-color: #dddddd}&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Initialising the array  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;$backgrounds = array(&amp;quot;LIGHTBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;, &amp;quot;DARKBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;);&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Building up the table  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;foreach ($foo as $i =&amp;gt; $j) {&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;array_push($backgrounds, ($bg = array_shift($backgrounds));&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;echo &amp;quot;&amp;amp;lt;TR CLASS=\&amp;quot;$bg\&amp;quot;&amp;amp;gt;&amp;quot;;&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;TD&amp;amp;gt;$i&amp;amp;lt;/TD&amp;amp;gt;&amp;amp;lt;TD&amp;amp;gt;$j&amp;amp;lt;/TD&amp;amp;gt;&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;/TR&amp;amp;gt;\n&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;};&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Explanation====&lt;br /&gt;
Each time around the loop  (here I've used a &amp;lt;tt&amp;gt;foreach&amp;lt;/tt&amp;gt; but it could be any kind of loop), the &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; (in the innermost brackets, so it gets evaluated first) causes a variable $bg to be set to the first element in $backgrounds and the others to be shifted down a place.  Then, this is pushed onto the tail end of the shortened array by the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt;.  So the whole array just gets recirculated, each time a value is read from the beginning it is moved to the end.  As the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; functions do not care about the length of the array, you could go through a whole rainbow of colours, or you could just alternate white and coloured rows.&lt;br /&gt;
&lt;br /&gt;
Note that if you want to use more than one table in your page, and you want them all to start on the same colour, you will have to re-create the array between finishing one table and starting the next.  This is because the array actually gets altered each time we go around the loop.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=PHP&amp;diff=1520</id>
		<title>PHP</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=PHP&amp;diff=1520"/>
		<updated>2004-03-06T02:49:03Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==PHP TIPS==&lt;br /&gt;
&lt;br /&gt;
===FANCY TABLES===&lt;br /&gt;
It is easy -- and it also looks really cool 8) -- to generate a table with alternating coloured rows from PHP.  What you have to do is&lt;br /&gt;
#Declare a CSS style class for each background colour.&lt;br /&gt;
#Create an array with the background colours in the order you want them to appear in the table.&lt;br /&gt;
#Place some code in the loop which generates the table, to set a background colour for each row.&lt;br /&gt;
&lt;br /&gt;
====Defining CSS Classes  (outside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;.DARKBG   {background-color: #bbbbbb}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.MIDDLEBG {background-color: #cccccc}&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;.LIGHTBG  {background-color: #dddddd}&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Initialising the array  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;$backgrounds = array(&amp;quot;LIGHTBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;, &amp;quot;DARKBG&amp;quot;, &amp;quot;MIDDLEBG&amp;quot;);&amp;lt;/tt&amp;gt;&lt;br /&gt;
====Building up the table  (inside &amp;amp;lt;? ?&amp;amp;gt;)====&lt;br /&gt;
:&amp;lt;tt&amp;gt;foreach ($foo as $i =&amp;gt; $j) {&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;array_push($backgrounds, ($bg = array_shift($backgrounds));&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;&amp;lt;strong&amp;gt;echo &amp;quot;&amp;amp;lt;TR CLASS=\&amp;quot;$bg\&amp;quot;&amp;amp;gt;&amp;quot;;&amp;lt;/strong&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;TD&amp;amp;gt;$i&amp;amp;lt;/TD&amp;amp;gt;&amp;amp;lt;TD&amp;amp;gt;$j&amp;amp;lt;/TD&amp;amp;gt;&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
::&amp;lt;tt&amp;gt;echo &amp;quot;&amp;amp;lt;/TR&amp;amp;gt;\n&amp;quot;;&amp;lt;/tt&amp;gt;&lt;br /&gt;
:&amp;lt;tt&amp;gt;};&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each time around the loop  (here I've used a &amp;lt;tt&amp;gt;foreach&amp;lt;/tt&amp;gt; but it could be any kind of loop), the &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; (in the innermost brackets, so it gets evaluated first) causes a variable $bg to be set to the first element in $backgrounds and the others to be shifted down a place.  Then, this is pushed onto the tail end of the shortened array by the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt;.  So the whole array just gets recirculated, each time a value is read from the beginning it is moved to the end.  As the &amp;lt;tt&amp;gt;array_push&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;array_shift&amp;lt;/tt&amp;gt; functions do not care about the length of the array, you could go through a whole rainbow of colours, or you could just alternate white and coloured rows.&lt;br /&gt;
&lt;br /&gt;
Note that if you want to use more than one table in your page, and you want them all to start on the same colour, you will have to re-create the array between finishing one table and starting the next.  This is because the array actually gets altered each time we go around the loop.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Programming_tips_%26_tricks&amp;diff=1437</id>
		<title>Programming tips &amp; tricks</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Programming_tips_%26_tricks&amp;diff=1437"/>
		<updated>2004-03-06T01:56:43Z</updated>

		<summary type="html">&lt;p&gt;Ajs318: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A [[bash]] example to get your IP address using http://www.whatismyip.com:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;B&amp;gt;lynx -dump http://www.whatismyip.com | grep &amp;quot;Your IP is&amp;quot;&amp;lt;/B&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or use this:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;/sbin/ifconfig ppp0 | grep inet | awk '{ printf(&amp;quot;%s\n&amp;quot;, substr($2,6)) }'&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Note that ppp0 stands for the first point-to-point-protocol device which is usually a modem. If you are using a network adapter instead, replace ppp0 with eth0.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Some counting examples:&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; x=$(expr $x + 1)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; x=$(echo $x + 1|bc)&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; let x=$x+1&amp;lt;br /&amp;gt;&lt;br /&gt;
x=0; ((x++))&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;p /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Combining multiple conditions of if statements&amp;lt;br /&amp;gt;&lt;br /&gt;
AND:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(a==1 &amp;amp;&amp;amp; b==2)&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
OR:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;if(a==(1|2|3)&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Python still does not have an intelligent compiler. So, when writing loops, you need to make sure of your tabs and spaces. As python does not implement braces under loops, it becomes essential to make sure of your spaces.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Re the previous comment on Python &amp;amp; braces: yes, Python uses indents or spaces instead of braces to delimit loops.  This is not a defect of the compiler but a design feature which helps make Python code easy to read.  Why not rely on space to show structure? - you're probably typing the indents anyway.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I have started a new page where I hope to share some [[PHP]] tips.&lt;/div&gt;</summary>
		<author><name>Ajs318</name></author>
	</entry>
</feed>