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.























{ 1 trackback } Trackback (1)
{ 4 comments… read them below or (4 komentáre ... prečítať nižšie alebo add one pridať jedno } )
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.lstI get this error I get this error
sed: -e expression #1, char 1: unknown command: ` 'bash: /^: No such file or directoryNote 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
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.newStill 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
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/hi, is this the same as: ahoj, je to rovnaké, ako:
grep -v '#' file grep-v '#' file
Leave a Comment Zanechať komentár