{"id":302452,"date":"2021-07-19T14:30:41","date_gmt":"2021-07-19T11:30:41","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-make-your-bash-scripts-hardware-aware-cloudsavvy-it\/"},"modified":"2021-07-19T14:30:41","modified_gmt":"2021-07-19T11:30:41","slug":"how-to-make-your-bash-scripts-hardware-aware-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-make-your-bash-scripts-hardware-aware-cloudsavvy-it\/","title":{"rendered":"#How to Make Your Bash Scripts Hardware Aware \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2d87c3d796b\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2d87c3d796b\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-make-your-bash-scripts-hardware-aware-cloudsavvy-it\/#Hardware_Aware_Scripts\" >Hardware Aware Scripts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-make-your-bash-scripts-hardware-aware-cloudsavvy-it\/#First_Steps_With_the_getconf_Command\" >First Steps With the getconf Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-make-your-bash-scripts-hardware-aware-cloudsavvy-it\/#Reporting_on_Single_Values\" >Reporting on Single Values<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-make-your-bash-scripts-hardware-aware-cloudsavvy-it\/#Using_getconf_With_File_System_Values\" >Using getconf With File System Values<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-make-your-bash-scripts-hardware-aware-cloudsavvy-it\/#Using_getconf_in_Scripts\" >Using getconf in Scripts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-make-your-bash-scripts-hardware-aware-cloudsavvy-it\/#Option_Overkill\" >Option Overkill<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Make Your Bash <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">Script<\/a>s Hardware Aware \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-4038\" srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Bash Shell\" width=\"1400\" height=\"600\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Writing scripts to run on different Linux computers is tough. You can\u2019t assume they\u2019ll have the same characteristics. The <code>getconf<\/code> command lets you check hundreds of operating system and file system values.<\/p>\n<h2 id=\"system-aware-scripts\"><span class=\"ez-toc-section\" id=\"Hardware_Aware_Scripts\"><\/span>Hardware Aware Scripts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you\u2019ve ever written a script that has to run on a variety of Linux machines, you might well have found yourself facing the \u201cStrange, it runs just fine on my machine\u2026\u201d quandary. Small differences between computer architecture, operating systems, and file systems on the target machines can prevent your scripts from operating correctly.<\/p>\n<p>If your scripts are simple and nothing they do\u2014or try to launch\u2014hinges on compatible hardware, or certain capabilities of the file system, you might never have an issue. But the more complicated your script becomes, the more critical are the details of the machine the script is running. It\u2019s also worth noting that a single computer can have several file systems installed on it, mounted on different parts of the directory tree. Because something works in one directory doesn\u2019t mean it\u2019ll work in the same way in another directory.<\/p>\n<p>The <code>getconf<\/code> command can report on literally hundreds of different operating system and file system characteristics. Some of these take the form of pairs of values, with one holding the system maximum and the other holding the minimum. This means you can test hardware or file system values to ensure your script will react accordingly.<\/p>\n<p>Of course, your script can\u2019t use <code>getconf<\/code> on the target computer if it isn\u2019t installed on that computer. All the distributions that were tested when researching this article had <code>getconf<\/code> already installed, including Ubuntu, Fedora, and Manjaro. Interestingly they all had the same version of <code>getconf<\/code> too, version 2.33.<\/p>\n<h2 id=\"first-steps-with-the-getconf-command\"><span class=\"ez-toc-section\" id=\"First_Steps_With_the_getconf_Command\"><\/span>First Steps With the getconf Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can check that you\u2019ve got <code>getconf<\/code> installed on your computer and find out which version it is, by using the <code>--version<\/code> option.<\/p>\n<pre>getconf --version<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12693\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/4a47a0db.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"210\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To see how many items <code>getconf<\/code> can report on, use the <code>-a<\/code> (all) option, and pipe it through the <code>wc<\/code> command. This will count the lines, words, and characters in the output.<\/p>\n<pre>getconf -a | wc<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12694\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/fb5c81ed.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"95\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>There are 320 lines in the output. To see the entire list in a manageable way, we\u2019ll pipe the output into <code>less<\/code> .<\/p>\n<pre>getconf -a | less<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12695\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/10fb15c7.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"55\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You can scroll forward and backward through to the list to see what <code>getconf<\/code>\u00a0can report on.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12697\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/09dd8c26.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Output from getconv -a in the less file viewer\" width=\"644\" height=\"380\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Some of the items are duplicates. Many of them can be called by a shorter name or by a longer POSIX-compliant name.<\/p>\n<h2 id=\"reporting-on-single-values\"><span class=\"ez-toc-section\" id=\"Reporting_on_Single_Values\"><\/span>Reporting on Single Values<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To cause <code>getconf<\/code> to report on a single value, pass the name of the value to <code>getconf<\/code> on the command line. Note that all the option names are in uppercase.<\/p>\n<pre>getconf LONG_BIT<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12698\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/8266e4bf.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"95\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The <code>LONG_BIT<\/code> option reports on whether your kernel\u2014and hence, your operating system\u2014is 32-bit or 64-bit. There are no other parameters required for this command, just the LONG_BIT option itself. Another simple value to report on is <code>LOGIN_NAME_MAX<\/code> .<\/p>\n<pre>getconf LOGIN_NAME_MAX<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12699\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/f19c9085.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"95\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>That\u2019s a strangely high maximum length for a user name, but it is true. If you really wanted to create a user account with a preposterously long user name, you could. By contrast, this computer\u2019s hostname has a maximum length of 64 characters:<\/p>\n<pre>getconf HOST_NAME_MAX<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12700\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/9eb9cd58.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"95\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To see how many simultaneous processes a user account can run, use the <code>CHILD_MAX<\/code> option:<\/p>\n<pre>getconf CHILD_MAX<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12701\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/602e8f04.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"95\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The <code>OPEN_MAX<\/code> value returns the maximum number of files a process can have open.<\/p>\n<pre>getconf OPEN_MAX<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12702\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/7afbb160.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"95\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To see a subset of the <code>getconf<\/code>values we can use the <code>-a<\/code> (all) option to generate all of the values, and use <code>grep<\/code> to filter out the ones we\u2019re interested in. For example, to see every value that has \u201cNAME\u201d in its title, use:<\/p>\n<pre>getconf -a | grep NAME<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12703\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/586e508f.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"245\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Likewise, to see all values with \u201cGROUP\u201d in their title, use:<\/p>\n<pre>getconf -a | grep GROUP<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12704\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/59b2900a.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"165\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To see the values that have \u201cINT_\u201d in their title, use:<\/p>\n<pre>getconf -a | grep _INT<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12705\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/9eb60bc8.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"125\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This shows the maximum and minimum values that an integer variable can hold on this computer.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How to Search with &#8220;grep&#8221; Using Strings in a File<\/em><\/strong><\/p>\n<h2 id=\"using-getconf-with-file-systems\"><span class=\"ez-toc-section\" id=\"Using_getconf_With_File_System_Values\"><\/span>Using getconf With File System Values<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When you use any of the options that relate to file system characteristics, you need to tell <code>getconf<\/code> which file system it should report on. You need to do this even if you only have a single hard drive and a single file system installed on it. The <code>getconf<\/code> command won\u2019t assume anything. To indicate the file system <code>getconf<\/code> should report on, you must provide a path to a directory in that file system.<\/p>\n<p>To see the maximum length for a file name for the file system mounted at the root of the file system directory tree, type:<\/p>\n<pre>getconf NAME_MAX \/<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12707\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/7b6fbd4c.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"95\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To see the result for a different file system, point to a directory located in the other file system. Even if you don\u2019t have different file systems permanently mounted in your directory tree, you can find yourself with another file system temporarily attached to your directory tree.<\/p>\n<p>This is exactly what happens when you insert a USB memory stick, like this example. The memory stick is called \u201cPINK\u201d and it is mounted at \u201c\/<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">media<\/a>\/dave\/.\u201d<\/p>\n<pre>getconf NAME_MAX \/media\/dave\/PINK\/<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12709\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/d642f8c3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"95\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We can check what file system is on the USB memory stick by using the <code>df<\/code> command to see what block device it is connected to. We then\u00a0use the <code>lsblk<\/code> command with the <code>-f<\/code> (file system) option.<\/p>\n<pre>df \/media\/dave\/PINK<\/pre>\n<pre>lsblk -f \/dev\/sdb1<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-12710 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/1e412544.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"210\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The memory stick is block device <code>\/dev\/sdb1<\/code> and the file system is <code>FAT32<\/code>. That\u201dll be why we get different results for two directories in the same directory tree. They\u2019re in the same directory tree, but they have different underlying file systems.<\/p>\n<p><strong>RELATED:<\/strong> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/73178\/what-file-system-should-i-use-for-my-usb-drive\/\"><strong><em>What File System Should I Use for My USB Drive?<\/em><\/strong><\/a><\/p>\n<h2 id=\"using-getconf-in-scripts\"><span class=\"ez-toc-section\" id=\"Using_getconf_in_Scripts\"><\/span>Using getconf in Scripts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We can easily incorporate the output from <code>getconf<\/code> in decisions inside our shell scripts.<\/p>\n<p>For example, to perform different actions depending on whether the script is running on a 32-bit or 64-bit operating system, you could use a section of script like this.<\/p>\n<pre>#!\/bin\/bash&#13;\n&#13;\n# are we on a 32 or 64 bit OS?&#13;\nif [ $(getconf LONG_BIT) = \"64\" ]&#13;\nthen&#13;\n  # 64 bit&#13;\n  echo \"64-bit machine.\"&#13;\nelse&#13;\n  # 32 bit&#13;\n  echo \"32-Bit machine.\"&#13;\nfi<\/pre>\n<p>The <code>if<\/code>\u00a0statement compares the output of the <code>getconf LONG_BIT<\/code>\u00a0command with the value of \u201c64.\u201d If they match, the\u00a0<code>then<\/code>\u00a0clause is executed otherwise the <code>else<\/code> clause is executed. You could either perform version-specific actions in the <code>then\/else<\/code>clauses or set variable flags that can be checked elsewhere in your script.<\/p>\n<p>Copy the script text into an editor and save your file as \u201chw-test.sh.\u201d We\u2019ll make the script executable with the <code>chmod<\/code> command and the <code>-x<\/code> (executable) option.<\/p>\n<pre>chmod +x hw-test.sh<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12711\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/c9baca3c.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"55\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>When we run the script it tells us which of the\u00a0clauses were triggered. Using this technique you could use any of the <code>getconf<\/code> values to direct your script to take the appropriate action.<\/p>\n<pre>.\/hw-test.sh<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12712\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/07\/88399fdc.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"644\" height=\"95\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 id=\"wrap-up\"><span class=\"ez-toc-section\" id=\"Option_Overkill\"><\/span>Option Overkill<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The sheer number of values that <code>getconf<\/code> can report on can be overwhelming. The <code>man<\/code> page is surprisingly brief. If you expect it to list the options and explain each one, you\u2019re going to be disappointed.<\/p>\n<p>You\u2019ll find some descriptions in the <code>man<\/code> pages for <code>sysconf<\/code> and <code>confstr<\/code>. You might need to trim a few characters off the front of the <code>confstr<\/code> entries. For example, this didn\u2019t work:<\/p>\n<pre>getconf\u00a0_CS_GNU_LIBC_VERSION<\/pre>\n<p>but this did:<\/p>\n<pre>getconf\u00a0GNU_LIBC_VERSION<\/pre>\n<p>You\u2019ll also find some descriptions in the \u201climits.h\u201d file. If you don\u2019t know where that file is on your system, use:<\/p>\n<pre>whereis limts.h <code\/><\/pre>\n<p>You can then use <code>less<\/code> to review that file.\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/12691\/how-to-make-your-bash-scripts-hardware-aware\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Make Your Bash Scripts Hardware Aware \u2013 CloudSavvy IT&#8221; Writing scripts to run on different Linux computers is tough. You can\u2019t assume they\u2019ll have the same characteristics. The getconf command lets you check hundreds of operating system and file system values. Hardware Aware Scripts If you\u2019ve ever written a script that has to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":302453,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-302452","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/302452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=302452"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/302452\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/302453"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=302452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=302452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=302452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}