<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.skytech.dk/index.php?action=history&amp;feed=atom&amp;title=Shell_scripting_-_goodies</id>
	<title>Shell scripting - goodies - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.skytech.dk/index.php?action=history&amp;feed=atom&amp;title=Shell_scripting_-_goodies"/>
	<link rel="alternate" type="text/html" href="https://wiki.skytech.dk/index.php?title=Shell_scripting_-_goodies&amp;action=history"/>
	<updated>2026-04-03T19:09:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.skytech.dk/index.php?title=Shell_scripting_-_goodies&amp;diff=1463&amp;oldid=prev</id>
		<title>80.166.222.82 at 09:47, 28 February 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.skytech.dk/index.php?title=Shell_scripting_-_goodies&amp;diff=1463&amp;oldid=prev"/>
		<updated>2008-02-28T09:47:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Linux]]&lt;br /&gt;
&lt;br /&gt;
= Input =&lt;br /&gt;
== Input from scripts/outside ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$$ = The PID number of the process executing the shell.&lt;br /&gt;
$? = Exit status variable.&lt;br /&gt;
$0 = The name of the command you used to call a program.&lt;br /&gt;
$1 = The first argument on the command line.&lt;br /&gt;
$2 = The second argument on the command line.&lt;br /&gt;
$n = The nth argument on the command line.&lt;br /&gt;
$* = All the arguments on the command line.&lt;br /&gt;
$# The number of command line arguments. &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Conditions =&lt;br /&gt;
==IF==&lt;br /&gt;
Checks available (if [ -&amp;lt;check&amp;gt; ])&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-b file = True if the file exists and is block special file.&lt;br /&gt;
-c file = True if the file exists and is character special file.&lt;br /&gt;
-d file = True if the file exists and is a directory.&lt;br /&gt;
-e file = True if the file exists.&lt;br /&gt;
-f file = True if the file exists and is a regular file&lt;br /&gt;
-g file = True if the file exists and the set-group-id bit is set.&lt;br /&gt;
-k file = True if the files&amp;#039; &amp;quot;sticky&amp;quot; bit is set.&lt;br /&gt;
-L file = True if the file exists and is a symbolic link.&lt;br /&gt;
-p file = True if the file exists and is a named pipe.&lt;br /&gt;
-r file = True if the file exists and is readable.&lt;br /&gt;
-s file = True if the file exists and its size is greater than zero.&lt;br /&gt;
-s file = True if the file exists and is a socket.&lt;br /&gt;
-t fd = True if the file descriptor is opened on a terminal.&lt;br /&gt;
-u file = True if the file exists and its set-user-id bit is set.&lt;br /&gt;
-w file = True if the file exists and is writable.&lt;br /&gt;
-x file = True if the file exists and is executable.&lt;br /&gt;
-O file = True if the file exists and is owned by the effective user id.&lt;br /&gt;
-G file = True if the file exists and is owned by the effective group id.&lt;br /&gt;
file1 –nt file2 = True if file1 is newer, by modification date, than file2.&lt;br /&gt;
file1 ot file2 = True if file1 is older than file2.&lt;br /&gt;
file1 ef file2 = True if file1 and file2 have the same device and inode numbers.&lt;br /&gt;
-z string = True if the length of the string is 0.&lt;br /&gt;
-n string = True if the length of the string is non-zero.&lt;br /&gt;
string1 = string2 = True if the strings are equal.&lt;br /&gt;
string1 != string2 = True if the strings are not equal.&lt;br /&gt;
!expr = True if the expr evaluates to false.&lt;br /&gt;
expr1 –a expr2 = True if both expr1 and expr2 are true.&lt;br /&gt;
expr1 –o expr2 = True is either expr1 or expr2 is true. &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== If (string and numeric check) ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(1) s1 = s2&lt;br /&gt;
(2) s1 != s2&lt;br /&gt;
(3) s1 &amp;lt; s2&lt;br /&gt;
(4) s1 &amp;gt; s2&lt;br /&gt;
(5) -n s1&lt;br /&gt;
(6) -z s1&lt;br /&gt;
(1) s1 matches s2&lt;br /&gt;
(2) s1 does not match s2&lt;br /&gt;
(3) __TO-DO__&lt;br /&gt;
(4) __TO-DO__&lt;br /&gt;
(5) s1 is not null (contains one or more characters)&lt;br /&gt;
(6) s1 is null&lt;br /&gt;
&lt;br /&gt;
            #!/bin/bash&lt;br /&gt;
            S1=&amp;#039;string&amp;#039;&lt;br /&gt;
            S2=&amp;#039;String&amp;#039;&lt;br /&gt;
            if [ $S1=$S2 ];&lt;br /&gt;
            then&lt;br /&gt;
                    echo &amp;quot;S1(&amp;#039;$S1&amp;#039;) is not equal to S2(&amp;#039;$S2&amp;#039;)&amp;quot;&lt;br /&gt;
            fi&lt;br /&gt;
            if [ $S1=$S1 ];&lt;br /&gt;
            then&lt;br /&gt;
                    echo &amp;quot;S1(&amp;#039;$S1&amp;#039;) is equal to S1(&amp;#039;$S1&amp;#039;)&amp;quot;&lt;br /&gt;
            fi&lt;br /&gt;
            &lt;br /&gt;
&lt;br /&gt;
11.4 Arithmetic relational operators&lt;br /&gt;
&lt;br /&gt;
-lt (&amp;lt;)&lt;br /&gt;
-gt (&amp;gt;)&lt;br /&gt;
-le (&amp;lt;=)&lt;br /&gt;
-ge (&amp;gt;=)&lt;br /&gt;
-eq (==)&lt;br /&gt;
-ne (!=) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Loop =&lt;br /&gt;
== For ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for NAME [in LIST ]; do COMMANDS; done&lt;br /&gt;
EX: for i in `cat list`; do cp &amp;quot;$i&amp;quot; &amp;quot;$i&amp;quot;.bak ; done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>80.166.222.82</name></author>
	</entry>
</feed>