mit Sed Text aus Datei nur nach dem ersten Treffer einfügen


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mit Sed Text aus Datei nur nach dem ersten Treffer einfügen
# 1  
Old 02-05-2010
mit Sed Text aus Datei nur nach dem ersten Treffer einfügen

Hello,

I'm new in Shell scripting but i should write a script, which inserts the license header out of a txt-File into the files in our Projekt. For the Java classes it runs without Problems but for XML files not. At xml-files i have to put the license Header after the xml-Header (?xml version="1.0" ... ?) but the xml Header is not only one line all the time, it could be about 2 or 3 lines.
first i tried with this.

Code:
sed '/?>/ r License_Header.txt' < xml-Datei.xml > tempFile.txt
mv tempFile.txt xml-Datei.xml

This is searching for the expression "?>" an insert the license Header after this expression and it also runs.
But if this Expression is in the file one more time, f.e. in another xml-header whis is in a comment, the shouldn't be insert again.

so i try to find a way, that only the first match was taken to consideration and hope that somebody can help me

thanks and sry for my verry bad english

Last edited by PhoenixONE; 02-05-2010 at 06:37 AM..
# 2  
Old 02-05-2010
Hello.

Per our forum rules, all posts must be in English.

We do provide translation services for posts from English to a number of languages as a benefit to users. However, posts must be in English.

Please repost in English.

Thank you for your cooperation.

The UNIX and Linux Forums.
# 3  
Old 02-05-2010
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. What is on Your Mind?

EdX - Founded by Harvard University and MIT in 2012

Is anyone actively learning, auditing or participating (for credit) at edX? There are some really great science and engineering programs there and they are all free to audit. For example, take a look at these classes related to: C Programming Quantum Physics Computer Science ... (6 Replies)
Discussion started by: Neo
6 Replies

2. Shell Programming and Scripting

Suchen und Ersetzen mit AWK

Hallo, ich habe mir mit meinen dürftigen Programmierkenntnissen ein Script zusammengebastelt über das ich in einem bestimmten Odner mit AWK alle Dateien eines Verzeichnis durchsuche und bestimmte Bezeichungen aller Dateien ändern kann. Es funktioniert auch soweit, nur hätte ich gerne auch die... (1 Reply)
Discussion started by: ruffi
1 Replies

3. Shell Programming and Scripting

Script mit Laufvariable schlanker gestalten?

Hiho. Ich habe mit meinen rudimentären Scriptkenntnissen folgendes nicht sehr elegantes Script geschrieben und würde es gern in einer etwas eleganteren Form haben. i=0 ... (2 Replies)
Discussion started by: Lock3
2 Replies

4. Shell Programming and Scripting

Script mit Laufvariable schlanker gestalten?

Hiho. Ich habe mit meinen rudimentären Scriptkenntnissen folgendes nicht sehr elegantes Script geschrieben und würde es gern in einer etwas eleganteren Form haben. i=0 ... (2 Replies)
Discussion started by: Lock3
2 Replies

5. Shell Programming and Scripting

shell script vorher batch mit curl

salve! this in windows command script (batch). i need it for mac....unix or linux @echo off Echo Router reconnect: AVM FRITZ!BOX FON WLAN 7170 curl "http://192.168.10.10:49000/upnp/control/WANIPConn1" -H "Content-Type: text/xml; charset="utf-8"" -H... (1 Reply)
Discussion started by: onkeldave
1 Replies

6. Shell Programming and Scripting

Bash: Zeilen aus Datei mit cat und grep in dynamisches Array schreiben

Hallo, ich habe eine Datei "Kino.ini" die z.B. wie folgt aussieht * KINOFILM A bla bla KINOFILM B blubb blubb KINOFILM C Ich möchte nun die Datei "Kino.ini" per cat und grep auslesen und testen ob der String KINOFILM nur mit einem '*' am Anfang vorkommt. In dieser Beispieldatei... (3 Replies)
Discussion started by: ABE2202
3 Replies

7. Shell Programming and Scripting

Simple script uploading *.dem files to an ftp

Hello.. i want to create a simple script that's upload all the *.dem files from one directory to ftp and then delete them. Any help? (3 Replies)
Discussion started by: TuXaKoS
3 Replies

8. UNIX for Dummies Questions & Answers

Xlib: Invalid MIT-MAGIC-COOKIE-1

Anyone: I have a very annoying problem on one of our servers (running Solaris 8). when ever I try to run "xhost +" with the display set at "localhost:0.0" I get the following error: xhost + Xlib: connection to "finappprod:0.0" refused by server Xlib: Invalid... (1 Reply)
Discussion started by: errolg
1 Replies
Login or Register to Ask a Question