I need to create a script that will add text after a specific line in a file (XML). Even I have so far:
resonance resonance "This script is blah blah" buzzing "-" press enter to proceed ... "clear var1 =` grep -n "& Lt; string & gt;" & lt; File & gt; | Awk -F ":" '{print $ 1}' `// var1 = line number function enterID () {echo -n" Enter ID: "Read ID var2 =" text to be added "sed" $ ( (Var1 + 1)) I $ var2 "& lt; File & gt; & Gt; & Lt; File & gt; // Add text to file, overwrite file # var1 = "$ ((1 var1 + 1))" // increase line number ??? Enter "echo echo" id successfully by adding "echo antirenvidu}" to Enweed (read {{read -p} "Enter to continue ..." clear echo -n "Do you want to add other IDs? (N) o: "Read the answer if [$ answer =" y "]; Then enterID and exit) EnterID
The script works around the first time. However, if users try to add an additional ID then the first ID is overwritten. I must also be sure that I am not a programmer (more of a network). I have a short experience script but it's all.
Additional information:
Basic:
& lt; Subscriber XML & gt; & Lt; Members & gt; & Lt; Customer Address = "0.0.0.0" id = "1" /> & Lt; Customer Address = "0.0.0.0" id = "2" /> & Lt; Customer Address = "0.0.0.0" id = "3" /> & Lt; Customer Address = "0.0.0.0" id = "4" /> & Lt; Customer Address = "0.0.0.0" id = "5" /> & Lt; / Member & gt; & Lt; / SubscriberXML & gt;
After the initial use:
& lt; SubscriberXML & gt; & Lt; Members & gt; & Lt; Customer Address = "0.0.0.0" id = "X" / & gt; // newly added ID & lt; Customer Address = "0.0.0.0" id = "1" /> & Lt; Customer Address = "0.0.0.0" id = "2" /> & Lt; Customer Address = "0.0.0.0" id = "3" /> & Lt; Customer Address = "0.0.0.0" id = "4" /> & Lt; Customer Address = "0.0.0.0" id = "5" /> & Lt; / Member & gt; & Lt; / SubscriberXML & gt;
After the second use:
& lt; SubscriberXML & gt; & Lt; Members & gt; & Lt; Customer Address = "0.0.0.0" id = "Y" /> // newly added ID & lt; Customer Address = "0.0.0.0" id = "1" /> & Lt; Customer Address = "0.0.0.0" id = "2" /> & Lt; Customer Address = "0.0.0.0" id = "3" /> & Lt; Customer Address = "0.0.0.0" id = "4" /> & Lt; Customer Address = "0.0.0.0" id = "5" /> & Lt; / Member & gt; & Lt; / SubscriberXML & gt;
Wish:
& lt; SubscriberXML & gt; & Lt; Members & gt; & Lt; Customer Address = "0.0.0.0" id = "Y" /> & Lt; Customer Address = "0.0.0.0" id = "X" / & gt; & Lt; Customer Address = "0.0.0.0" id = "1" /> & Lt; Customer Address = "0.0.0.0" id = "2" /> & Lt; Customer Address = "0.0.0.0" id = "3" /> & Lt; Customer Address = "0.0.0.0" id = "4" /> & Lt; Customer Address = "0.0.0.0" id = "5" /> & Lt; / Member & gt; & Lt; / SubscriberXML & gt;
You can not:
Any_command File & gt; The file will process shell redress on first , and the file will be first and launch the shell command. There are blank files in the command. There are some techniques:
-
Use a temporary file and overwrite the original file if the command is successfully completed
Temporary = $ (mktemp) any_command file & gt; "$ Temporary" & amp; Amp; Install the moreutils
package and use sponge
command ; Mv "$ temp" file
-
> any_command file | Sponge file
Comments
Post a Comment