<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6138235623347299872</id><updated>2024-10-24T06:52:25.321-07:00</updated><category term="mysql"/><category term="query"/><category term="awk"/><category term="command awk"/><category term="insert"/><category term="insert ignore"/><category term="select"/><category term="select dalam select"/><category term="sql"/><category term="unix"/><title type='text'>Shared of Experiences</title><subtitle type='html'>Always Sharing Knowledge Though Slightly</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://supehe.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6138235623347299872/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://supehe.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/00384347146102845227</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6138235623347299872.post-18554613026658912</id><published>2012-01-18T18:50:00.000-08:00</published><updated>2012-02-14T18:51:54.431-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="insert"/><category scheme="http://www.blogger.com/atom/ns#" term="insert ignore"/><category scheme="http://www.blogger.com/atom/ns#" term="mysql"/><category scheme="http://www.blogger.com/atom/ns#" term="query"/><title type='text'>INSERT IGNORE</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEEUVEAB3uIRBxmegJA-084N80r4SGyk1b4emI2PICHPP_QSzuOiuAvZyOac9SA5BU2IATTvAsGXKLiuDcFb-kdTeukuSy710EAMIxO5UWmvTdfgliqTPXwrUHeZTPeUkgELRW3Zrt1zKg/s1600/insert-logo.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEEUVEAB3uIRBxmegJA-084N80r4SGyk1b4emI2PICHPP_QSzuOiuAvZyOac9SA5BU2IATTvAsGXKLiuDcFb-kdTeukuSy710EAMIxO5UWmvTdfgliqTPXwrUHeZTPeUkgELRW3Zrt1zKg/s200/insert-logo.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;An error will occur when entering a new record in MySQL, if the primary key specified in the insert query already exists. Using the keyword &quot;IGNORE&quot; to prevent errors occur because there is a duplication of records and other queries can still be executed.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;&lt;b&gt;Why ??&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;You should not try to insert a record without first checking if the primary key you want to use already exists, there may be time for this query is required, such as when some developers need to update their own data backups of the database, and a particular record may already exist in other database tables.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;&lt;b&gt;Inserting a single record&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;The Query is very simple, just add &quot;IGNORE&quot; after &quot;INSERT&quot; as:&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #cccccc; background-image: initial; background-origin: initial; border-bottom-color: rgb(102, 102, 102); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(102, 102, 102); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(102, 102, 102); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(102, 102, 102); border-top-style: solid; border-top-width: 1px; clear: both; font-size: 11px; overflow-x: auto; overflow-y: hidden; padding-bottom: 1em; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black;&quot;&gt;INSERT IGNORE INTO pegawai
    (primaryKey, NIK, no_meja)
VALUES
    (&#39;abc&#39;, 1, 2);&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;&lt;b&gt;Inserting multiple records&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;When inserting multiple records at once, record the exact same as the above data will be ignored and that no records will be in the right insert.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #cccccc; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: rgb(102, 102, 102); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(102, 102, 102); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(102, 102, 102); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(102, 102, 102); border-top-style: solid; border-top-width: 1px; clear: both; font-size: 11px; overflow-x: auto; overflow-y: hidden; padding-bottom: 1em; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black;&quot;&gt;INSERT IGNORE INTO pegawai
    (primaryKey, NIK, no_meja)
VALUES
    (&#39;abc&#39;, 1, 2),
    (&#39;def&#39;, 3, 4),
    (&#39;ghi&#39;, 5, 6);&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;Well from the above data, record &#39;abc&#39;, 1, 2 will not be in the insert because the data already exists.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;&lt;b&gt;Conclusion&lt;/b&gt;&amp;nbsp;:&amp;nbsp;Insert ignore used when we want to add records are records that may already exist in the table in the insert so that no data redundancy (duplicate).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;Don&#39;t miss it&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;vote web ini yaa &lt;a href=&quot;http://tiny.cc/b82is&quot;&gt;klik disini!!&lt;/a&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://supehe.blogspot.com/feeds/18554613026658912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://supehe.blogspot.com/2012/01/insert-ignore.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6138235623347299872/posts/default/18554613026658912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6138235623347299872/posts/default/18554613026658912'/><link rel='alternate' type='text/html' href='http://supehe.blogspot.com/2012/01/insert-ignore.html' title='INSERT IGNORE'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/00384347146102845227</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEEUVEAB3uIRBxmegJA-084N80r4SGyk1b4emI2PICHPP_QSzuOiuAvZyOac9SA5BU2IATTvAsGXKLiuDcFb-kdTeukuSy710EAMIxO5UWmvTdfgliqTPXwrUHeZTPeUkgELRW3Zrt1zKg/s72-c/insert-logo.jpg" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>Jakarta Capital Region 12970, Indonesia</georss:featurename><georss:point>-6.211544 106.845172</georss:point><georss:box>-6.464111 106.52931500000001 -5.958977 107.161029</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6138235623347299872.post-4340497940520059511</id><published>2012-01-18T02:04:00.000-08:00</published><updated>2012-02-14T18:52:12.922-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mysql"/><category scheme="http://www.blogger.com/atom/ns#" term="query"/><category scheme="http://www.blogger.com/atom/ns#" term="select"/><category scheme="http://www.blogger.com/atom/ns#" term="select dalam select"/><category scheme="http://www.blogger.com/atom/ns#" term="sql"/><title type='text'>Select the select query (double select)</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt1M-quodrLyhMzzUsLrU4nYdpNhSILDzK6rVl43u4wNdw83uugMK6d7DkH5J8f7s7RHcrl93ttBujmc7wbYJRrXUVAnMbKK8RmBNkNmixTufsXyMjaKvr1Vr3cWqSQCzI5T83OKgJ25Fp/s1600/execute_query_print_logo.gif&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt1M-quodrLyhMzzUsLrU4nYdpNhSILDzK6rVl43u4wNdw83uugMK6d7DkH5J8f7s7RHcrl93ttBujmc7wbYJRrXUVAnMbKK8RmBNkNmixTufsXyMjaKvr1Vr3cWqSQCzI5T83OKgJ25Fp/s1600/execute_query_print_logo.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
Running SELECT query in the SELECT will need to do when we want to retrieve database information let the results more quickly. The conventional way which is often used is to query 2 times so that the processing will take longer.&lt;br /&gt;
Well as an example, we will create a table in a database table that province, which contains the name of the province and population.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;border-bottom-color: windowtext; border-bottom-style: none; border-bottom-width: 1pt; border-left-color: windowtext; border-left-style: none; border-left-width: 1pt; border-right-color: windowtext; border-right-style: none; border-right-width: 1pt; border-top-color: windowtext; border-top-style: none; border-top-width: 1pt; font-family: Consolas; line-height: 115%; padding-bottom: 0in; padding-left: 0in; padding-right: 0in; padding-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f3f3f3; font-size: x-small;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;CREATE TABLE `propinsi` (&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;`nama_propinsi` varchar(100) collate
latin1_general_ci NOT NULL,&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;`jumlah_penduduk` int(20) unsigned NOT
NULL,&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;PRIMARY KEY&amp;nbsp;&amp;nbsp;(`nama_propinsi`)&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;) ENGINE=MyISAM DEFAULT CHARSET=latin1
COLLATE=latin1_general_ci;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-color: initial; border-color: initial; border-style: initial; border-style: initial;&quot;&gt;&lt;span id=&quot;more-151&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-color: initial; border-color: initial; border-style: initial; border-style: initial;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;INSERT INTO `propinsi` VALUES (&#39;Jatim&#39;, 100000);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;INSERT INTO `propinsi` VALUES (&#39;Jateng&#39;,
200000);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;INSERT INTO `propinsi` VALUES (&#39;Jabar&#39;,
300000);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;INSERT INTO `propinsi` VALUES (&#39;DKI
Jakarta&#39;, 400000);&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;border-bottom-color: windowtext; border-bottom-style: none; border-bottom-width: 1pt; border-left-color: windowtext; border-left-style: none; border-left-width: 1pt; border-right-color: windowtext; border-right-style: none; border-right-width: 1pt; border-top-color: windowtext; border-top-style: none; border-top-width: 1pt; color: #444444; font-family: Consolas; font-size: 7.5pt; line-height: 115%; padding-bottom: 0in; padding-left: 0in; padding-right: 0in; padding-top: 0in;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
Once the table is formed, we will create a query to display the name of the province whose total population is larger than the population of the province jateng.&lt;br /&gt;
Logic generally we find first the total population (n) jateng province, and then we are looking for a larger population of n earlier. 2 query&#39;s happening ..&lt;br /&gt;
In this case, we will use a SELECT query in the select:&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;border-bottom-color: windowtext; border-bottom-style: none; border-bottom-width: 1pt; border-left-color: windowtext; border-left-style: none; border-left-width: 1pt; border-right-color: windowtext; border-right-style: none; border-right-width: 1pt; border-top-color: windowtext; border-top-style: none; border-top-width: 1pt; font-family: Consolas; line-height: 115%; padding-bottom: 0in; padding-left: 0in; padding-right: 0in; padding-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white; font-size: x-small;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;select nama_propinsi from propinsi where
jumlah_penduduk &amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Consolas; line-height: 115%;&quot;&gt;(select jumlah_penduduk from propinsi where
nama_propinsi=&#39;Jateng&#39;);&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white; font-size: x-small;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-color: initial; border-style: initial;&quot;&gt;
&lt;br /&gt;
The output of the query are the provinces of West Java and Jakarta, which means that provincial population is larger than the population of the province of West Java and Central Java is Jakarta.&lt;br /&gt;
&lt;br /&gt;
So, select the SELECT query is enough to use when we need a filter from another table in one database&lt;br /&gt;
&lt;br /&gt;
Well it is quite simple.&lt;br /&gt;
&lt;br /&gt;
Hopefully this information useful.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;Don&#39;t miss it&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;vote web ini yaa&amp;nbsp;&lt;a href=&quot;http://tiny.cc/b82is&quot;&gt;klik disini!!&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://supehe.blogspot.com/feeds/4340497940520059511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://supehe.blogspot.com/2012/01/query-select-dalam-select_18.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6138235623347299872/posts/default/4340497940520059511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6138235623347299872/posts/default/4340497940520059511'/><link rel='alternate' type='text/html' href='http://supehe.blogspot.com/2012/01/query-select-dalam-select_18.html' title='Select the select query (double select)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/00384347146102845227</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt1M-quodrLyhMzzUsLrU4nYdpNhSILDzK6rVl43u4wNdw83uugMK6d7DkH5J8f7s7RHcrl93ttBujmc7wbYJRrXUVAnMbKK8RmBNkNmixTufsXyMjaKvr1Vr3cWqSQCzI5T83OKgJ25Fp/s72-c/execute_query_print_logo.gif" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>Jakarta Capital Region, Indonesia</georss:featurename><georss:point>-6.211544 106.845172</georss:point><georss:box>-6.464111 106.52931500000001 -5.958977 107.161029</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6138235623347299872.post-8416058920210539434</id><published>2012-01-18T00:05:00.000-08:00</published><updated>2012-02-14T18:52:31.779-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="awk"/><category scheme="http://www.blogger.com/atom/ns#" term="command awk"/><category scheme="http://www.blogger.com/atom/ns#" term="unix"/><title type='text'>Command AWK</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 13px; line-height: 21px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; font-size: 1em; line-height: 1.65em; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQDNSI0yCAfTSNMwGmcMKuePP5MHnzvZhIy6kKF-ojk7U8MgI-kh9x8j_s4rmrTvLNFzaQEsj_tCfhn10rsVnnO4VB9rsj3njLOgoBFNBUyCrNUCB5HqnaYzy0PjU_SJP_bTRbV_Cy6Sjk/s1600/images.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;195&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQDNSI0yCAfTSNMwGmcMKuePP5MHnzvZhIy6kKF-ojk7U8MgI-kh9x8j_s4rmrTvLNFzaQEsj_tCfhn10rsVnnO4VB9rsj3njLOgoBFNBUyCrNUCB5HqnaYzy0PjU_SJP_bTRbV_Cy6Sjk/s200/images.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Shell script&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;As a novice in the world&#39;s script&#39; shell, the command &#39;awk&#39; is something that must I understand to be the level further. Why? because &#39;awk&#39; proved to simplify my current job&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;Well, Let&#39;s go ..&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;What is the real &#39;awk&#39; it?&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;&#39;AWK&#39; asalah utility similar to &#39;sed&#39; which serves to find a pattern in a file and perform an operation. &#39;AWK&#39; own stands behind the names of its creators, namely Alfred V. Aho, Peter J. Weinberger, and Brian W. Kernighan. Hmm ... that&#39;s it seemed as the introduction of &#39;awk&#39;, we just go into how to use it.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;Now we try the basics first ...&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1em; line-height: 1.65em;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 15px; line-height: normal; white-space: pre;&quot;&gt;bash-3.00$ date&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre style=&quot;font-size: 15px;&quot;&gt;Mon May 17 10:29:45 WIB 2010
bash-3.00$ date | awk &#39;{print $1}&#39;
Mon
bash-3.00$ date | awk &#39;{print $4}&#39;
10:30:01
bash-3.00$ date | awk &#39;{print $3,$2}&#39;
17 May
bash-3.00$ date | awk &#39;{print $3$2}&#39;
17May&lt;/pre&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;&#39;Awk&#39; can also be used in arithmetic operations, like addition (+), subtraction (-), multiplication (*), division (/), the rest of the division / modulus (%), and so on. For its use, can be seen in the following example:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre style=&quot;font-size: 15px;&quot;&gt;bash-3.00$ echo 2 3 | awk &#39;{print $1 + $2}&#39;
5
bash-3.00$ echo 2 3 | awk &#39;{print $1 - $2}&#39;
-1
bash-3.00$ echo 2 3 | awk &#39;{print $1 * $2}&#39;
6
bash-3.00$ echo 2 3 | awk &#39;{print $1 / $2}&#39;
0.666667
bash-3.00$ echo 5 3 | awk &#39;{print $1 % $2}&#39;
2&lt;/pre&gt;
&lt;pre style=&quot;font-size: 15px;&quot;&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;This time we will go next step make the script into a file and run it.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;first create a file with a name&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 1em; line-height: 1.65em;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;font-size: 1em; line-height: 1.65em;&quot;&gt;pelanggan.awk&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre style=&quot;font-size: 15px;&quot;&gt;bash-3.00$ vi pelanggan.awk

EXCELCOMINDO  INCOMING   42542    32230    254786
HUTCHINSON    INCOMING   2456     16953    573586
MOBILE-8      INCOMING   15944    11477    692939
MOBILSEL      INCOMING   1680     91188    951394
NATRINDO      INCOMING   2198     19826    154859&lt;/pre&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;After that we &lt;b&gt;save&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;Now make the script. Create a file named&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 1em; line-height: 1.65em;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;font-size: 1em; line-height: 1.65em;&quot;&gt;print.awk&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;font-size: 15px;&quot;&gt;bash-3.00$ vi print.awk

BEGIN {
  print &quot;\tKolom 1\tKolom 2&quot;
  kolom1=0
  kolom2=0
}
{
  kolom1+=$3
  kolom2+=$4
  print &quot;\t&quot;$3&quot;\t&quot;$4
}
{
  kolom3=kolom1/5
  kolom4=kolom2/5
}
END {
    print &quot;Jumlah:&quot;kolom1&quot;\t&quot;kolom2
    print &quot;Rata:\t&quot;kolom3&quot;\t&quot;kolom4
}&lt;/pre&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;Then &lt;b&gt;save&lt;/b&gt;. To menjalanakannya type:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;font-size: 15px;&quot;&gt;bash-3.00$ awk -f print.awk pelanggan.awk&lt;/pre&gt;
&lt;div style=&quot;font-size: 1em; line-height: 1.65em;&quot;&gt;
The result:&lt;/div&gt;
&lt;pre style=&quot;font-size: 15px;&quot;&gt;        Kolom 1    Kolom 2
        42542      32230
        2456       16953
        15944      11477
        1680       91188
        2198       19826

Jumlah: 64820      171674
Rata:   12964      34334.8&lt;/pre&gt;
&lt;pre style=&quot;font-size: 15px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 16px; line-height: 26px; white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px; white-space: normal;&quot;&gt;All functions that are owned by the &#39;awk&#39; can also be used together. For example, I want to add up the size of some files starting character file name is abe, then simply by typing:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px;&quot;&gt;bash-3.00$ ls -l abe* | awk &#39;{sum=sum + $5} END {print sum}&#39;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;div style=&quot;font-size: 15px; text-align: justify;&quot;&gt;
197904&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px; white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;At the command ls-l shows the field size of a file is on the field to-five ($ 5), ls-l abe * be used to list files beginning with abe. As for the command &#39;awk&#39; is used a variable sum to save the sum of $ 5 on each line / file name, the last line in the file list is displayed the value of the variable sum.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;Actually there are very many secrets of &#39;awk&#39;. Finally, Thanks for your attention and good bye&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: normal; text-align: -webkit-auto;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;Don&#39;t miss it&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: normal; text-align: -webkit-auto;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 26px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif;&quot;&gt;vote web ini yaa&amp;nbsp;&lt;a href=&quot;http://tiny.cc/b82is&quot;&gt;klik disini!!&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://supehe.blogspot.com/feeds/8416058920210539434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://supehe.blogspot.com/2012/01/command-awk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6138235623347299872/posts/default/8416058920210539434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6138235623347299872/posts/default/8416058920210539434'/><link rel='alternate' type='text/html' href='http://supehe.blogspot.com/2012/01/command-awk.html' title='Command AWK'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/00384347146102845227</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQDNSI0yCAfTSNMwGmcMKuePP5MHnzvZhIy6kKF-ojk7U8MgI-kh9x8j_s4rmrTvLNFzaQEsj_tCfhn10rsVnnO4VB9rsj3njLOgoBFNBUyCrNUCB5HqnaYzy0PjU_SJP_bTRbV_Cy6Sjk/s72-c/images.jpg" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>Jakarta Capital Region, Indonesia</georss:featurename><georss:point>-6.211544 106.845172</georss:point><georss:box>-6.464111 106.52931500000001 -5.958977 107.161029</georss:box></entry></feed>