bash - How to print a character using Shell script -


below script acquire mac of machine , store within config file.

my problem within each line have character " " , dont print inside file, how can write file using " "

mac=$(ifconfig eth0 | grep -o -e '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}') echo " view.sslverificationmode = *3* view.autoconnectdesktop = *true* view.autoconnectbroker = *true* view.kiosklogin = *true* view.noninteractive = *true* view.fullscreen = *true* view.nomenubar = *true* view.defaultbroker = *viewcs* view.defaultuser = *cm-${mac//:/_}* " > /etc/vmware/view-mandatory-config; sed -i 's/*/"/g' /etc/vmware/view-mandatory-config 

with cat , here-doc can use multi-line input without escaping charaters

mac=$(ifconfig eth0 | grep -o -e '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}') cat << eot > /etc/vmware/view-mandatory-config view.sslverificationmode = "3" view.autoconnectdesktop = "true" view.autoconnectbroker = "true" view.kiosklogin = "true" view.noninteractive = "true" view.fullscreen = "true" view.nomenubar = "true" view.defaultbroker = "viewcs" view.defaultuser = "cm-${mac//:/_}" eot 

cat relay stdin input generated here document stdout, enabling redirection file


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -