• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Tuesday, May 13, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

How to View Configuration Files Without Comments in Linux

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
41
VIEWS
Share on FacebookShare on Twitter

Are you looking through an extremely lengthy configuration file, one with hundreds of lines of comments, but only want to filter the important settings from it. In this article, we will show you different ways to view a configuration file without comments in Linux.

Read Also: ccat – Show ‘cat Command’ Output with Syntax Highlighting or Colorizing

You can use the grep command to for this purpose. The following command will enable you view the current configurations for PHP 7.1 without any comments, it will remove lines starting with the ; character which is used for commenting.

Note that since ; is a special shell character, you need to use the / escape character to change its meaning in the command.

$ grep ^[^/;] /etc/php/7.1/cli/php.ini
How to View Configuration Files Without Comments in Linux

View Files Without Comments

In most configuration files, the # character is used for commenting out a line, so you can use the following command.

$ grep ^[^#] /etc/postfix/main.cf

What if you have lines starting with some spaces or tabs other then # or ; character?. You can use the following command which should also remove empty spaces or lines in the output.

$ egrep -v "^$|^[[:space:]]*;" /etc/php/7.1/cli/php.ini 
OR
$ egrep -v "^$|^[[:space:]]*#" /etc/postfix/main.cf
How to View Configuration Files Without Comments in Linux

View Files Without Spaces

From the above example, the -v switch means show non-matching lines; instead of showing matched lines (it actually inverts the meaning of matching) and in the pattern “^$|^[[:space:]]*#”:

  • ^$ – enables for deleting empty spaces.
  • ^[[:space:]]*# or ^[[:space:]]*; – enables matching of lines that starting with # or ; or “some spaces/tabs.
  • | – the infix operator joins the two regular expressions.

Also learn more about grep command and its variations in these articles:

  1. What’s Difference Between Grep, Egrep and Fgrep in Linux?
  2. 11 Advanced Linux ‘Grep’ Commands on Character Classes and Bracket Expressions

That’s all for now! We would love to hear from you, share with us any alternative methods for viewing configuration files without comments, via the feedback form below.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

Discus – Show Colourised Disk Space Usage in Linux

Next Post

20 Netstat Commands for Linux Network Management

Next Post

20 Netstat Commands for Linux Network Management

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet