15 lines
368 B
Bash
15 lines
368 B
Bash
#!/bin/bash
|
|
function comment_line() {
|
|
local regex="${1:?}"
|
|
local file="${2:?}"
|
|
local comment_mark="${3:-#}"
|
|
sed -ri "s:^([ ]*)($regex):\\1$comment_mark\\2:" "$file"
|
|
}
|
|
|
|
function uncomment_line() {
|
|
local regex="${1:?}"
|
|
local file="${2:?}"
|
|
local comment_mark="${3:-#}"
|
|
sed -ri "s:^([ ]*)[$comment_mark]+[ ]?([ ]*$regex):\\1\\2:" "$file"
|
|
}
|