<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dikapediav2.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Bash_Scripting</id>
	<title>Bash Scripting - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://dikapediav2.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Bash_Scripting"/>
	<link rel="alternate" type="text/html" href="https://dikapediav2.com/wiki/index.php?title=Bash_Scripting&amp;action=history"/>
	<updated>2026-05-15T09:14:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://dikapediav2.com/wiki/index.php?title=Bash_Scripting&amp;diff=33&amp;oldid=prev</id>
		<title>Ardika Sulistija: Created page with &quot;  My fave cheatsheet site: https://devhints.io/bash   How to commit scripts to GitHub: [http://dikapedia.com/wiki/index.php/Git Git]&lt;/br&gt;   [https://github.com/ardikas/Shell-scripts Ardika&#039;s GitHub Repo]   Add:  netstat -plan | awk &#039;/.*[0-9]+.[0-9]+.[0-9]+.[0-9].*/{gsub(/::ffff:/,&quot;&quot;,$0);print $4&quot;\t&quot; $5}&#039;|cut -sd. -f 1-&gt;netstat.log;echo &quot;Netstat  report&quot;;echo;echo &quot;Number of Connections to each port:&quot;;cat netstat.log |awk {&#039;print $1&#039;}|cut -d: -f 2|sort|uniq -c|sort -nk 1|...&quot;</title>
		<link rel="alternate" type="text/html" href="https://dikapediav2.com/wiki/index.php?title=Bash_Scripting&amp;diff=33&amp;oldid=prev"/>
		<updated>2024-08-20T13:31:56Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;  My fave cheatsheet site: https://devhints.io/bash   How to commit scripts to GitHub: [http://dikapedia.com/wiki/index.php/Git Git]&amp;lt;/br&amp;gt;   [https://github.com/ardikas/Shell-scripts Ardika&amp;#039;s GitHub Repo]   Add:  netstat -plan | awk &amp;#039;/.*[0-9]+.[0-9]+.[0-9]+.[0-9].*/{gsub(/::ffff:/,&amp;quot;&amp;quot;,$0);print $4&amp;quot;\t&amp;quot; $5}&amp;#039;|cut -sd. -f 1-&amp;gt;netstat.log;echo &amp;quot;Netstat  report&amp;quot;;echo;echo &amp;quot;Number of Connections to each port:&amp;quot;;cat netstat.log |awk {&amp;#039;print $1&amp;#039;}|cut -d: -f 2|sort|uniq -c|sort -nk 1|...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
My fave cheatsheet site: https://devhints.io/bash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How to commit scripts to GitHub: [http://dikapedia.com/wiki/index.php/Git Git]&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ardikas/Shell-scripts Ardika&amp;#039;s GitHub Repo]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add:&lt;br /&gt;
 netstat -plan | awk &amp;#039;/.*[0-9]+.[0-9]+.[0-9]+.[0-9].*/{gsub(/::ffff:/,&amp;quot;&amp;quot;,$0);print $4&amp;quot;\t&amp;quot; $5}&amp;#039;|cut -sd. -f 1-&amp;gt;netstat.log;echo &amp;quot;Netstat  report&amp;quot;;echo;echo &amp;quot;Number of Connections to each port:&amp;quot;;cat netstat.log |awk {&amp;#039;print $1&amp;#039;}|cut -d: -f 2|sort|uniq -c|sort -nk 1|tail;echo;echo  &amp;quot;Number of connections from each IP:&amp;quot;;cat netstat.log |awk {&amp;#039;print $2&amp;#039;}|cut -d: -f 1|sort|uniq -c|sort -nk 1|tail;echo;echo &amp;quot;The number of instances of a particular IP connecting to particular port&amp;quot;;cat netstat.log |awk {&amp;#039;print $1 &amp;quot;\t&amp;quot; $2&amp;#039;}|cut -d: -f 2|sort|uniq -c|sort -nk 1|tail;&lt;br /&gt;
&lt;br /&gt;
Wanted to share a quick netstat &amp;quot;tally&amp;quot; script I wrote, that I&amp;#039;ve found to be useful on several occasions:&lt;br /&gt;
&lt;br /&gt;
Shows top 10 IPs holding connections, as well as a breakdown of active connnections by port. Useful for troubleshooting connection flooding issues as well as helps making usage based recommendations for things like Apache spare server settings etc. Hope some of you may find it helpful.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====For loop====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Basic for loop to create 30 users:&lt;br /&gt;
 # for i in {1..30}; &lt;br /&gt;
 &amp;gt; do useradd user$i; &lt;br /&gt;
 &amp;gt; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For loop to delete the line in files that contains string &amp;quot;aws-replication&amp;quot; &lt;br /&gt;
 # cat /usr/bin/forloop.sh &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 etc_file=$(grep -irl &amp;quot;aws-replication&amp;quot; /home/ec2-user/)&lt;br /&gt;
 &lt;br /&gt;
 for file in &amp;quot;etc_file&amp;quot;; do&lt;br /&gt;
     ls -al $etc_file&lt;br /&gt;
     sed -i  &amp;#039;/aws-replication/d&amp;#039; $etc_file  &lt;br /&gt;
 &lt;br /&gt;
 done&lt;br /&gt;
 -----------------------&lt;br /&gt;
 &lt;br /&gt;
 # grep -i &amp;quot;aws-replication&amp;quot; /home/ec2-user/test2&lt;br /&gt;
 aws-replication:!!:19200::::::&lt;br /&gt;
 &lt;br /&gt;
 # grep -i &amp;quot;aws-replication&amp;quot; /home/ec2-user/test&lt;br /&gt;
 disk:x:6:aws-replication&lt;br /&gt;
 aws-replication:x:1001:&lt;br /&gt;
 &lt;br /&gt;
 # /usr/bin/forloop.sh &lt;br /&gt;
 ---------- 1 root root 705 Jul 27 18:22 /home/ec2-user/test&lt;br /&gt;
 ---------- 1 root root 705 Jul 27 18:22 /home/ec2-user/test2&lt;br /&gt;
 &lt;br /&gt;
 # grep -i &amp;quot;aws-replication&amp;quot; /home/ec2-user/test&lt;br /&gt;
 # grep -i &amp;quot;aws-replication&amp;quot; /home/ec2-user/test2&lt;br /&gt;
 # (no output as lines were deleted)&lt;/div&gt;</summary>
		<author><name>Ardika Sulistija</name></author>
	</entry>
</feed>