How to remove # in front of a line with sed?

Houman

I'm trying to uncomment (removing #) the line sql.

session {
        radutmp

        #
        #  See "Simultaneous Use Checking Queries" in sql.conf
#       sql
}

This is what I've tried:

sed -i 's/#       sql/        sql/' /etc/freeradius/sites-available/inner-tunnel

But somehow the spaces are not correctly calculated. It doesn't find # sql.

hek2mgl

Following melpomene it looks like the input file is using tabs instead of spaces. You can use the [:blank:] character class which includes both tabs and spaces:

sed '/#[[:blank:]]*sql/s/#//' file

The command matches lines with the sequence #, zero or more spaces followed by the term sql and removes the first #

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to remove <?xml at *start of line* with sed?

How to remove one line from repository with sed

How to remove pattern line if next line is empty using sed

How to remove anything behind symbol each line but don't remove the text in front of each line

How to remove only the first occurrence of a line in a file using sed

How to remove odd lines except for first line using SED or AWK

how to remove both first and last line of csv file using sed

How can I remove the first line of a file with sed?

How to use sed or another command line function to remove . between characters

how to remove last comma from line in bash using "sed or awk"

How do I remove a line if it begins with a . or a > using sed?

How to remove comma in the last line of sed address range?

While using sed, how to remove \n with \t if a line ends with number

sed: How to remove the first blank line after a pattern match

Use sed to remove characters in front of matching keywords

SED remove spaces and line breaks

SED to remove a Line with REGEX Pattern

Use sed to remove part of a line

How to remove the N th target word(='remove_mark') in a line by sed?

How to use sed to remove all trailing Q's, but not remove the last Q if the line is all Q's

How to remove versions with sed

How to remove data with sed

How to remove these symbols with sed

How to format a line with Sed

How to remove spaces in front of punctuation

sed remove ze if ze is alone on the line

remove only the first blank line sed

sed remove special characters and spaces in line

sed - match on IP octet and remove line