How to view a configuration file without the comments Ako zobraziť konfiguračný súbor bez komentára

by Sukrit Dhandhania on May 22, 2009 používateľa Sukrit Dhandhania 22. mája 2009

Linux

I have to often make changes to configuration files such as httpd.conf and squid.conf . Musím často vykonávať zmeny v konfiguračných súborov, napríklad httpd.conf a squid.conf. These files have a large number of lines that are commented out, mostly comments and some possible configuration directives that have been commented out as they are not required by default. Tieto súbory majú veľké množstvo položiek, ktoré sú zakomentované, väčšinou pripomienok a niektoré z možných konfiguračných direktiv, ktoré boli komentoval tak, ako nie sú vyžadované v predvolenom nastavení. A problem I face while editing such files is that there are so many lines commented out that I need to scroll down many lines before I can find the next active configuration directive. Problém som tvár pri editácii takýchto súborov je, že existuje toľko riadkov poznamenal, že som potrebné posunúť nadol veľa riadkov, ako sa mi podarí nájsť ďalšie aktívne konfiguračné direktívy. I found a fine solution to help me out with this. Našiel som pokutu riešenie, pomôžte mi s tým.

I now use the following command when I want to just look at the active directives in the Apache configuration file: Teraz zadajte nasledujúci príkaz, keď chcem len pozrieť na aktívnu smerníc v konfiguračnom súbore Apache:

# sed '/ *#/d; /^ *$/d' /etc/httpd/conf/httpd.conf # Sed '/ * # / d; / ^ * $ / d' / etc / httpd / conf / httpd.conf

This command reads the file /etc/httpd/conf/httpd.conf and filters out all the comments and extra white spaces, leaving just the active configuration settings. Tento príkaz prečíta súbor / etc / httpd / conf / httpd.conf a odfiltruje všetky pripomienky a ďalšie biele miesta, takže len aktívnym nastavenia konfigurácie. This makes it very easy for me to look at the configuration file. Vďaka tomu je veľmi ľahké pre mňa pozrieť sa na konfiguračný súbor.

If you want to just filter out the lines that begin with comments run the following command: Ak chcete odfiltrovať iba riadky, ktoré začínajú s pripomienkami zadajte nasledujúci príkaz:

# sed '/ ^#/d; /^ *$/d' /etc/httpd/conf/httpd.conf # Sed '/ ^ # / d; / ^ * $ / d' / etc / httpd / conf / httpd.conf

It's pretty much the same command as earlier with a small change. Je to skoro rovnaký príkaz ako predtým s malou zmenou. The first * is replaced by ^ , which is regex for beginning of line. * Prvý nahrádza ^, čo je výraz pre začiatok riadku.

Related Posts: Súvisiace zmeny:
  • How to open and view .cbr and .cbz files Ako otvoriť a zobraziť. Cbr a. CBZ súbory
  • How to view the page source in a new tab using Firefox Ako zobraziť zdrojový kód stránky v novom paneli pomocou Firefoxu
  • Contact Kontakt
  • How to create a symlink (shortcut) in Linux Ako vytvoriť symbolický odkaz (zástupcu) v Linuxu
  • 10 more brightkite invites for Simple Help readers 10 viac brightkite pozýva pre čitateľa Simple Help
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Get Help jednoduchá cvičenie, rovnako ako to vo vašej e-mailovej schránky každý deň - zadarmo! Just enter your email address below: Stačí zadať e-mailovú adresu:

    You can always opt out of this email subscription at any time. Vždy sa môžete odhlásiť z tohto e-mailu predplatného kedykoľvek.

    { 1 trackback } Trackback (1)

    Display files without commented-out lines « Linux & Stuff Zobraziť súbory, bez uviedol-out linky «Linux & Stuff
    05.31.09 at 3:51 am 05.31.09 v 351: am

    { 4 comments… read them below or (4 komentáre ... prečítať nižšie alebo add one pridať jedno } )

    1 1 paulfxh 05.30.09 at 3:20 pm paulfxh 05.30.09 v 3:20 pm

    Your command to show a file without comments could be very useful for me. Váš príkaz na zobrazenie súboru bez pripomienok, by mohlo byť veľmi užitočné pre mňa.
    However, when I tried to run Avšak, keď som sa snažil bežať
    # sed '/ ^#/d; /^ *$/d' /boot/grub/menu.lst
    I get this error I get this error
    sed: -e expression #1, char 1: unknown command: ` '
    bash: /^: No such file or directory
    Note that I copied/pasted the command directly from your post. Všimnite si, že som skopírovať a vložiť príkaz priamo z vašich príspevkov.
    I have a feeling this may be a HTML-related problem. Mám pocit, že to môže byť HTML-súvisiace problém.
    Any clues? Any clues?
    Thanks Vďaka
    Paul Paul

    2 2 paulfxh 05.31.09 at 3:16 am paulfxh 05.31.09 v 316: am

    Well, after a bit of searching around, I found that this command does what I want No, po troche hľadania v okolí, som zistil, že tento príkaz robí, čo chcem
    sed '/^#/ d' /boot/grub/menu.lst>/boot/grub/menu.new
    Still not sure exactly what's wrong with the command given in the article, but it might be that the HTML has somehow 'distorted' the first single quote mark Stále nie je istý, čo presne sa stalo s príkazom uvedeným v článku, ale to by mohlo byť, že HTML sa nejako 'skreslený' prvý singel úvodzovkách

    3 3 paulfxh 05.31.09 at 3:33 am paulfxh 05.31.09 v 333: am

    After a little more experimentation, I find that the command below does what the command in the article was intended to do Po trochu experimentovanie, zistil som, že príkaz pod čo robí príkaz v článku mal robiť
    sed '/^#/d; /^*$/d' /path/to/file/

    4 4 lxtips lxtips 06.29.09 at 10:03 pm 06.29.09 o 10:03 hod

    hi, is this the same as: ahoj, je to rovnaké, ako:

    grep -v '#' file grep-v '#' file

    Leave a Comment Zanechať komentár

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> Môžete použiť tieto HTML tagy a atribúty: href = "" <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> del datetime <em> <i> <q Cite=""> <strike> <strong>