What's new

Helper script question

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

octopus

Part of the Furniture
I'm using "pc insert" but there is a bug in new alpha build.
I can use "pc_repalce" but need a raw 1 and raw 2.

pc replace " raw 1" " raw 1 new raw raw 2" $CONFIG
like
raw 1
raw 2

someone have any suggestions?

Thanks
octopus
 
You could directly use sed.
 
I'm not sure I follow exactly what it is you're doing, but the helper functions are just human-friendly wrappers for sed. So use sed directly:

sed -i "/$PATTERN/a$CONTENT" $CONFIG

You just have to be careful if $PATTERN or $CONTENT might contain any non-alphanumeric characters.
 
You could also just reuse the pc_insert() code from 384.9.
 
Who knows from description but perhaps problem could be solved with delete and append
Code:
pc_delete "dhcp-option=dnsf5" $CONFIG
pc_delete "dhcp-option=dnsf6" $CONFIG
pc_append "dhcp-script=/jffs/scripts/log-dhcp.sh" $CONFIG
pc_append "neg-ttl=3600" $CONFIG
pc_delete "no-negcache" $CONFIG
pc_delete "servers-file=/tmp/resolv.dnsmasq" $CONFIG
 
I'm not sure I follow exactly what it is you're doing, but the helper functions are just human-friendly wrappers for sed. So use sed directly:

sed -i "/$PATTERN/a$CONTENT" $CONFIG

You just have to be careful if $PATTERN or $CONTENT might contain any non-alphanumeric characters.

You could directly use sed.
You could also just reuse the pc_insert() code from 384.9

Thank you Colins your suggestion working fine. Thank you RMerlin.
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top