<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>Angel's Blog</title>
		<link>https://angelcool.net/sphpblog/blog_index.php</link>
		<description><![CDATA[No Footer]]></description>
		<copyright>Copyright 2026, Angel</copyright>
		<managingEditor>Angel</managingEditor>
		<language>en-US</language>
		<generator>SPHPBLOG 0.7.0</generator>
		<item>
			<title>Using GNU comm to compare sorted files line by line. </title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry241218-034133</link>
			<description><![CDATA[This is similar to PHP&#039;s array_diff and Java&#039;s removeAll(). Helpful in finding diffs between lists of ids.<br /><br /><pre>angelcool@fedora-laptop$cat FILE1.txt <br />1<br />2<br />3<br />4<br />5<br />5<br />angelcool@fedora-laptop$cat FILE2.txt <br />1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />angelcool@fedora-laptop$comm -13 &lt;(sort FILE1.txt|uniq) &lt;(sort FILE2.txt|uniq)<br />6<br />7<br />8<br />9<br />angelcool@fedora-laptop$ man comm<br />...<br />       Compare sorted files FILE1 and FILE2 line by line.<br /><br />       When FILE1 or FILE2 (not both) is -, read standard input.<br /><br />       With  no  options,  produce three-column output.  Column one contains lines unique to FILE1, column two con‐<br />       tains lines unique to FILE2, and column three contains lines common to both files.<br /><br />       -1     suppress column 1 (lines unique to FILE1)<br /><br />       -2     suppress column 2 (lines unique to FILE2)<br /><br />       -3     suppress column 3 (lines that appear in both files)<br /><br />       --check-order<br />              check that the input is correctly sorted, even if all input lines are pairable<br /><br />       --nocheck-order<br />              do not check that the input is correctly sorted<br /><br />       --output-delimiter=STR<br />              separate columns with STR<br /><br />       --total<br />              output a summary<br /><br />       -z, --zero-terminated<br />              line delimiter is NUL, not newline<br /><br />       --help display this help and exit<br /><br />       --version<br />              output version information and exit<br /><br />       Note, comparisons honor the rules specified by &#039;LC_COLLATE&#039;.<br />...</pre>]]></description>
			<category>- Bash Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry241218-034133</guid>
			<author>Angel</author>
			<pubDate>Wed, 18 Dec 2024 03:41:33 GMT</pubDate>
		</item>
		<item>
			<title>BASH Fun: Running a command at a specific time using &#039;at&#039;.</title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry190415-230317</link>
			<description><![CDATA[<pre>[acool@acool2 ~]$ sudo yum install at<br />...<br />[acool@acool2 ~]$ sudo systemctl start atd<br />[acool@acool2 ~]$ sudo systemctl enable atd<br /><br /><br />[acool@acool2 ~]$ date<br />Mon Apr 15 16:09:15 PDT 2019<br />[acool@acool2 ~]$ <br />[acool@acool2 ~]$ echo &#039;date &gt;&gt; at-fun.txt&#039;  | at now + 1 minute<br />job 79 at Mon Apr 15 16:10:00 2019<br />[acool@acool2 ~]$ <br />[acool@acool2 ~]$ atq<br />79	Mon Apr 15 16:10:00 2019 a acool<br />[acool@acool2 ~]$ <br />[acool@acool2 ~]$ cat at-fun.txt <br />Mon Apr 15 16:10:00 PDT 2019<br /><br /><br />[acool@acool2 ~]$ <br />[acool@acool2 ~]$ cat at-fun.txt <br />[acool@acool2 ~]$ echo &#039;php -v &gt;&gt; at-fun.txt&#039;  | at 4:16 PM April 15 2019<br />job 84 at Mon Apr 15 16:16:00 2019<br />[acool@acool2 ~]$ <br />[acool@acool2 ~]$ date<br />Mon Apr 15 16:15:21 PDT 2019<br />[acool@acool2 ~]$ atq<br />84	Mon Apr 15 16:16:00 2019 a acool<br />[acool@acool2 ~]$ <br />[acool@acool2 ~]$ cat at-fun.txt <br />PHP 7.0.27 (cli) (built: Apr  4 2018 13:48:44) ( NTS )<br />Copyright (c) 1997-2017 The PHP Group<br />Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies<br />[acool@acool2 ~]$ <br /></pre><br /><a href="https://stackoverflow.com/questions/55524769/running-cli-at-command-via-php-permissions-issues" >https://stackoverflow.com/questions/55524769</a>]]></description>
			<category>- Bash Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry190415-230317</guid>
			<author>Angel</author>
			<pubDate>Mon, 15 Apr 2019 23:03:17 GMT</pubDate>
		</item>
		<item>
			<title>Memcached: Looping through a set of servers to delete a key.</title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry190415-174259</link>
			<description><![CDATA[Cool way to make sure a key does not exist in a group of memcached servers. Handy when troubleshooting or when cached data needs a purge. Tested:<br /><PRE>[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ for i in {1..6};do ( echo &#039;delete events.slick-range&#039;) | nc  server-${i}.example.com 11211; done;<br />NOT_FOUND<br />NOT_FOUND<br />NOT_FOUND<br />DELETED<br />NOT_FOUND<br />NOT_FOUND<br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ </PRE><br />Try adding a delay if the above doesn&#039;t seem to work:<br /><PRE>[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ for i in {1..6};do ( sleep 2; echo &#039;delete events.slick-range&#039;) | nc -d 2  server-${i}.example.com 11211; done;<br />NOT_FOUND<br />NOT_FOUND<br />NOT_FOUND<br />DELETED<br />NOT_FOUND<br />NOT_FOUND<br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ </PRE><br /><br /><br /><br />BONUS (6/12/2019) - Find out the expiration date for a key:<br /><pre>(sleep 1; echo &quot;stats cachedump 7 0&quot;; sleep 1; echo &quot;quit&quot;;) | nc www-server01.example.com  11211 | grep &#039;memc.sess.tpnm0jd8aottlturb0ml510sd0&#039;</pre><br /><br />Increase/decrease the slab (seven) number as need until the key is found.]]></description>
			<category>- Bash Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry190415-174259</guid>
			<author>Angel</author>
			<pubDate>Mon, 15 Apr 2019 17:42:59 GMT</pubDate>
		</item>
		<item>
			<title>BASH: Looping through all lines in a file</title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry160215-025758</link>
			<description><![CDATA[Content of getThem.sh :<br /><pre>cd logos;<br /><br />while read line; do<br /><br />   # test if line starts with &quot;assets&quot;<br />   if [[ $line =~ ^asset.* ]]; then<br />     #prepend domain<br />     line=&quot;http://www.soy-example.com/$line&quot;<br />   fi<br />  <br />   # test if line starts with &quot;/assets&quot;<br />   if [[ $line =~ ^/asset.* ]]; then<br />     # prepend domain<br />     line=&quot;http://www.soy-example.com$line&quot;<br />   fi<br />  <br />   # download this sucker<br />   wget $line<br /><br />done &lt; ../soyFranquiciasLogos.txt</pre>]]></description>
			<category>- Bash Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry160215-025758</guid>
			<author>Angel</author>
			<pubDate>Mon, 15 Feb 2016 02:57:58 GMT</pubDate>
		</item>
		<item>
			<title>BASH 101: Dollar sign madness</title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry150825-183905</link>
			<description><![CDATA[positional parameters, parameters passed to script.<br /><pre>$1, $2, $3, ... </pre><br />It&#039;s an array-like construct of all positional parameters, {$1, $2, $3 ...}.<br /><pre>&quot;$@&quot; </pre><br />It&#039;s the IFS expansion of all positional parameters, $1 $2 $3 ....<br /><pre>&quot;$*&quot; </pre><br />It&#039;s the number of positional parameters.<br /><pre>$# </pre><br />current options set for the shell.<br /><pre>$- </pre><br />pid of the current shell (not subshell).<br /><pre>$$ </pre><br />most recent parameter (or the abs path of the command to start the current shell immediately after startup).<br /><pre>$_ </pre><br />It&#039;s the (input) field separator.<br /><pre>$IFS </pre><br />It&#039;s the most recent foreground pipeline exit status.<br /><pre>$? </pre><br />It&#039;s the PID of the most recent background command.<br /><pre>$!</pre><br />It&#039;s the name of the shell or shell script.<br /><pre>$0</pre><br /><br /><a href="http://stackoverflow.com/questions/5163144/what-are-the-special-dollar-sign-shell-variables" >http://stackoverflow.com/questions/5163 ... -variables</a>]]></description>
			<category>- Bash Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry150825-183905</guid>
			<author>Angel</author>
			<pubDate>Tue, 25 Aug 2015 18:39:05 GMT</pubDate>
		</item>
		<item>
			<title>BASH 101: Functions</title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry150814-182159</link>
			<description><![CDATA[EXAMPLE A) Declaring a function in sum.sh script:<br /><pre>#!/usr/bin/bash<br /><br />sum()<br />{<br />   echo $1 + $2 | bc<br />}<br /><br /># call function and pass cli<br /># parameters to function<br />sum $1 $2<br /></pre><br />Calling script:<br /><pre>[aesteban@localhost ~]$ ./sum.sh 1.4 1.3<br />2.7</pre><br />EXAMPLE B) A different way to write sum.sh script:<br /><pre>#!/usr/bin/bash<br /><br />sum()<br />{<br />   RESULT=$(echo $1+$2 | bc) # or: RESULT=`echo $1+$2 | bc`<br />}<br /><br />sum $1 $2<br /><br />echo $RESULT<br /></pre><br />Calling modified script:<br /><pre>[aesteban@localhost ~]$ ./sum.sh 1.7 1.2<br />2.9</pre><br />EXAMPLE C) Another way to write the same crap:<br /><pre>#!/usr/bin/bash<br /><br />sum()<br />{<br />   echo $1+$2 | bc<br />}<br /><br />SUMRESULT=`sum $1 $2`<br /><br />echo $SUMRESULT<br /></pre><br />Calling it:<br /><pre>[aesteban@localhost ~]$ ./sum.sh 2.9 3<br />5.9</pre>]]></description>
			<category>- Bash Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry150814-182159</guid>
			<author>Angel</author>
			<pubDate>Fri, 14 Aug 2015 18:21:59 GMT</pubDate>
		</item>
		<item>
			<title>BASH 101: Notes</title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry150527-205800</link>
			<description><![CDATA[<pre>#local variables<br />[aesteban@localhost ~]$ Name=Angel<br />[aesteban@localhost ~]$ echo $Name<br />Angel<br />[aesteban@localhost ~]$ Name=&quot;Angel Cool&quot;<br />[aesteban@localhost ~]$ echo $Name<br />Angel Cool<br />[aesteban@localhost ~]$ #readonly<br />[aesteban@localhost ~]$ readonly Name<br />[aesteban@localhost ~]$ Name=&quot;Angel Esteban&quot;<br />bash: Name: readonly variable<br />[aesteban@localhost ~]$<br /><br />#index arrays<br />[aesteban@localhost ~]$ Fruits[0]=apple<br />[aesteban@localhost ~]$ Fruits[1]=orange<br />[aesteban@localhost ~]$ Fruits[2]=banana<br />[aesteban@localhost ~]$ Fruits[3]=grapes<br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ States=(&quot;California&quot; &quot;Texas&quot; &quot;Florida&quot;)<br />[aesteban@localhost ~]$ echo ${States[1]}<br />Texas<br /><br />[aesteban@localhost ~]$ echo ${Fruits[2]}<br />banana<br />[aesteban@localhost ~]$ echo ${Fruits[*]}<br />apple orange banana grapes<br />[aesteban@localhost ~]$ echo ${#Fruits[*]}<br />4<br />[aesteban@localhost ~]$ unset Fruits<br />[aesteban@localhost ~]$ echo ${!States[*]}<br />0 1 2<br />[aesteban@localhost ~]$<br /><br />#associative arrays<br />[aesteban@localhost ~]$ declare -A INFO<br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ INFO[&quot;name&quot;]=&quot;Angel Esteban Cool&quot;<br />[aesteban@localhost ~]$ echo ${INFO[&quot;name&quot;]}<br />Angel Esteban Cool<br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ INFO=([name]=&quot;Angel Cool&quot; [website]=&quot;angelcool.net&quot;)<br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ echo ${INFO[&quot;website&quot;]}<br />angelcool.net<br />[aesteban@localhost ~]$<br /></pre><br /><br />Loops<br /><pre>[aesteban@localhost ~]$ for i in $(seq 1 5); do echo This line corresponds to line $i.;done;<br />This line corresponds to line 1.<br />This line corresponds to line 2.<br />This line corresponds to line 3.<br />This line corresponds to line 4.<br />This line corresponds to line 5.<br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ for i in {1..7}; do echo This is number $i.;done;<br />This is number 1.<br />This is number 2.<br />This is number 3.<br />This is number 4.<br />This is number 5.<br />This is number 6.<br />This is number 7.<br />[aesteban@localhost ~]$<br />[aesteban@localhost var]$ for i in `ls /var`;do echo $i;done;<br /> ...<br />[aesteban@localhost ~]$# looping through a list of servers<br />[aesteban@localhost ~]$for i in {1..5}; do ssh www-app0${i} &quot;cd /var/www/html/barney.com &amp;&amp; git pull origin live&quot; ;done;<br /> </pre>]]></description>
			<category>- Bash Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry150527-205800</guid>
			<author>Angel</author>
			<pubDate>Wed, 27 May 2015 20:58:00 GMT</pubDate>
		</item>
	</channel>
</rss>
