{"id":11206,"date":"2019-03-11T06:44:27","date_gmt":"2019-03-11T06:44:27","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11206"},"modified":"2019-03-11T06:44:27","modified_gmt":"2019-03-11T06:44:27","slug":"ccat-show-cat-command-output-with-syntax-highlighting-or-colorizing","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/11\/ccat-show-cat-command-output-with-syntax-highlighting-or-colorizing\/","title":{"rendered":"ccat \u2013 Show \u2018cat Command\u2019 Output with Syntax Highlighting or Colorizing"},"content":{"rendered":"<p><strong>ccat<\/strong>\u00a0is command line similar to\u00a0<a href=\"https:\/\/www.tecmint.com\/13-basic-cat-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">cat command<\/a>\u00a0in Linux that displays the content of a file with syntax highlighting for the following programming languages:\u00a0<strong>Javascript<\/strong>,\u00a0<strong>Java<\/strong>,\u00a0<strong>Go<\/strong>,\u00a0<strong>Ruby<\/strong>,\u00a0<strong>C<\/strong>,\u00a0<strong>Python<\/strong>\u00a0and\u00a0<strong>Json<\/strong>.<\/p>\n<p>To install\u00a0<strong>ccat<\/strong>\u00a0utility in your Linux distribution, first assure that the\u00a0<a href=\"https:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">wget utility<\/a>\u00a0is present in your system. If the\u00a0<a href=\"https:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">wget command<\/a>\u00a0line is not installed in the system, issue the below command to install it:<\/p>\n<pre># yum install wget        [On CentOS\/RHEL\/Fedora]\r\n# apt-get install wget    [On Debian and Ubuntu]\r\n<\/pre>\n<p>In order to install the latest version of\u00a0<strong>ccat<\/strong>\u00a0command line via the latest compiled binaries, first download the compressed tarball by issuing the below command. The binary and source code releases archives can be found at the official\u00a0<a href=\"https:\/\/github.com\/jingweno\/ccat\/releases\" target=\"_blank\" rel=\"nofollow noopener\">ccat github webpage<\/a>.<\/p>\n<pre><strong>-------------- On 64-Bit --------------<\/strong> \r\n# wget https:\/\/github.com\/jingweno\/ccat\/releases\/download\/v1.1.0\/linux-amd64-1.1.0.tar.gz \r\n\r\n<strong>-------------- On 32-Bit --------------<\/strong> \r\n# wget https:\/\/github.com\/jingweno\/ccat\/releases\/download\/v1.1.0\/linux-386-1.1.0.tar.gz \r\n<\/pre>\n<p>After archive download completes, list the current working directory to show the files, extract the\u00a0<strong>ccat tarball<\/strong>(the\u00a0<strong>linux-amd64-1.x.x<\/strong>\u00a0Tarball file) and copy the\u00a0<strong>ccat<\/strong>\u00a0executable binary from the extracted tarball into a Linux executable system path, such as\u00a0<strong>\/usr\/local\/bin\/<\/strong>\u00a0path, by issuing the below commands.<\/p>\n<pre># ls\r\n# tar xfz linux-amd64-1.1.0.tar.gz \r\n# ls linux-amd64-1.1.0\r\n# cp linux-amd64-1.1.0\/ccat \/usr\/local\/bin\/\r\n# ls -al \/usr\/local\/bin\/\r\n<\/pre>\n<div id=\"attachment_28122\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/ccat-Command-Executable-Files.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28122\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/ccat-Command-Executable-Files.png\" alt=\"ccat Command Executable Files\" width=\"521\" height=\"205\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">ccat Command Executable Files<\/p>\n<p>If for some reasons the\u00a0<strong>ccat<\/strong>\u00a0file from your executable system path has no executable bit set, issue the below command to set executable permissions for all system users.<\/p>\n<pre># chmod +x \/usr\/local\/bin\/ccat\r\n<\/pre>\n<p>In order to test\u00a0<strong>ccat<\/strong>\u00a0utility capabilities against a system configuration file, issue the below commands. The content of the displayed files should be highlighted according to file programming language sytnax, as illustrated in the below command examples.<\/p>\n<pre># ccat \/etc\/sysconfig\/network-scripts\/ifcfg-ens33 \r\n# ccat \/etc\/fstab \r\n<\/pre>\n<div id=\"attachment_28123\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/ccat-Command-Usage.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28123\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/ccat-Command-Usage.png\" sizes=\"auto, (max-width: 793px) 100vw, 793px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/ccat-Command-Usage.png 793w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/ccat-Command-Usage-768x486.png 768w\" alt=\"ccat Command Usage\" width=\"793\" height=\"502\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">ccat Command Usage<\/p>\n<\/div>\n<p>In order to replace\u00a0<a href=\"https:\/\/www.tecmint.com\/13-basic-cat-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">cat command<\/a>\u00a0with\u00a0<strong>ccat command<\/strong>\u00a0system wide, add a bash alias for\u00a0<strong>ccat<\/strong>\u00a0in system\u00a0<strong>bashrc<\/strong>file, log out from the system and log in back again to apply the configuration.<\/p>\n<pre><strong>-------------- On CentOS, RHEL &amp; Fedora --------------<\/strong> \r\n# echo \"alias cat='\/usr\/local\/bin\/ccat'\" &gt;&gt; \/etc\/bashrc \r\n# exit\r\n\r\n<strong>-------------- On Debiab &amp; Ubuntu --------------<\/strong> \r\n# echo \"alias cat='\/usr\/local\/bin\/ccat'\" &gt;&gt; \/etc\/profile\r\n# exit\r\n<\/pre>\n<p>Finally, run\u00a0<strong>cat command<\/strong>\u00a0against an arbitrary configuration file to test if\u00a0<strong>ccat<\/strong>\u00a0alias has replaced\u00a0<strong>cat command<\/strong>, as shown in the below example. The output file syntax should be highlighted now.<\/p>\n<pre># cat .bashrc\r\n<\/pre>\n<div id=\"attachment_28124\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Replace-cat-Command-with-ccat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28124\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Replace-cat-Command-with-ccat.png\" alt=\"Replace cat Command with ccat\" width=\"374\" height=\"356\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Replace cat Command with ccat<\/p>\n<\/div>\n<p><strong>ccat<\/strong>\u00a0utility can also be used to concatenate multiple files and display the output in HTML format, as illustrated in the below example.<\/p>\n<pre># ccat --html \/etc\/fstab \/etc\/sysconfig\/network-scripts\/ifcfg-ens33&gt; \/var\/www\/html\/ccat.html\r\n<\/pre>\n<p>However, you will need a web server installed in your system, such as Apache HTTP server or Nginx, to display the content of the HTML file, as illustrated in the below screenshot.<\/p>\n<div id=\"attachment_28125\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Display-File-Content-in-HTML.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28125\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Display-File-Content-in-HTML.png\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Display-File-Content-in-HTML.png 776w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Display-File-Content-in-HTML-768x536.png 768w\" alt=\"Display File Content in HTML\" width=\"776\" height=\"542\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Display File Content in HTML<\/p>\n<\/div>\n<p>For other custom configurations and command options visit\u00a0<a href=\"https:\/\/github.com\/jingweno\/ccat\" target=\"_blank\" rel=\"nofollow noopener\">ccat official github<\/a>\u00a0page.<\/p>\n<p><a style=\"font-size: 1rem;\" href=\"https:\/\/www.tecmint.com\/cat-command-output-with-syntax-highlighting-or-color\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>ccat\u00a0is command line similar to\u00a0cat command\u00a0in Linux that displays the content of a file with syntax highlighting for the following programming languages:\u00a0Javascript,\u00a0Java,\u00a0Go,\u00a0Ruby,\u00a0C,\u00a0Python\u00a0and\u00a0Json. To install\u00a0ccat\u00a0utility in your Linux distribution, first assure that the\u00a0wget utility\u00a0is present in your system. If the\u00a0wget command\u00a0line is not installed in the system, issue the below command to install it: # yum &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/11\/ccat-show-cat-command-output-with-syntax-highlighting-or-colorizing\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ccat \u2013 Show \u2018cat Command\u2019 Output with Syntax Highlighting or Colorizing&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11206","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11206"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11206\/revisions"}],"predecessor-version":[{"id":11207,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11206\/revisions\/11207"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}