Can not understand this script

Posted by Jim on Super User See other posts from Super User or by Jim
Published on 2012-10-22T08:13:42Z Indexed on 2012/10/22 11:05 UTC
Read the original article Hit count: 231

Filed under:
|
|
|
|

Can someone help me understand this script? It is from sysconf_add and I am new to scripting.
I need to do something similar.

function add_word() {  
    local word=$1  
    local word_quoted=$2  
    if ! word_present; then  
        $debug && cp $file $tmpf  
        sed -i -e "${lineno} {   
            s/^[[:space:]]*\($var=\".*\)\(\".*\)/\1 $word_quoted\2/;   
            s/=\" /=\"/   
            }" $file  
        $debug && diff -u $tmpf $file  
    else  
        echo \"$word\" already present  
    fi  
    # some balancing for vim"s syntax highlighting  
}  

© Super User or respective owner

Related posts about linux

Related posts about bash