This post has been edited 5 times, last edit by "DarkWolve" (Feb 16th 2008, 6:35pm)
This post has been edited 1 times, last edit by "Benjamin" (Feb 16th 2008, 6:41pm)
Source code |
|
1 2 3 4 5 6 7 8 9 |
#! /bin/bash for i in `ls` do dat=`grep -l text $i` if [ -s $dat ] then "anzuhängender Text">>$dat fi done |
Guru
Date of registration: Dec 11th 2001
Location: Hämelerwald
Occupation: Wissenschaftlicher Mitarbeiter (Forschungszentrum L3S, TU Braunschweig)
Was soll durchsucht werden? Was genau bedeutet "darunter"? Nenn' doch am besten die vollständige Aufgabenstellung, sonst kann Dir hier niemand helfen, der nicht zufällig auch gerade mit dieser Lehrveranstaltung zu tun hat ...In der Klausur 2007_02 soll man ein Script schreiben, welches nach nem Text sucht und darunter eine Zeile anhängt!
Source code |
|
1 |
then "anzuhängender Text">>$dat |
scriptname >>filename
appends the output of scriptname to file filename. If filename does not already exist, it is created.
COMMAND_OUTPUT >>
# Redirect stdout to a file.
# Creates the file if not present, otherwise appends to it.
In der Klausur 2007_02 soll man ein Script schreiben, welches nach nem Text sucht und darunter eine Zeile anhängt!
This post has been edited 1 times, last edit by "sos1981" (Feb 16th 2008, 8:18pm)
Zerschmetterling
Date of registration: Aug 31st 2003
Location: Hannover
Occupation: Informatikstudent (d'uh)
Source code |
|
1 2 3 4 5 6 7 8 9 |
#!/bin/bash oder # !/bin/bash for i in * oder ./* do zeile=`grep -m 1 -n "# (c) SRA" $i | cut -d ":" -f 1` zeile2=`grep -m 1 -n "grep -m 1 -n" $i | cut -d ":" -f 1` if [ $zeile ] then if [ ! $zeile2 -a $zeile2=$zeile ] (...) |
Source code |
|
1 |
sed 's/\(# (c) SRA.*\)/\1\nanzuhängender Text/;' filename |
This post has been edited 1 times, last edit by "Benjamin" (Feb 17th 2008, 12:14pm)
Zerschmetterling
Date of registration: Aug 31st 2003
Location: Hannover
Occupation: Informatikstudent (d'uh)
Tatsache! Hier für's Forum habe ich das Skript aus Ilias kopiert, da steht die Zeile:
Eigentlich wollte ich ja auch nur an diesen Ausschnitt der Man-page ran, die uns dazu gegeben worden ist und daran komm ich leider auch nicht über die Lösung mehr dran.
Zerschmetterling
Date of registration: Aug 31st 2003
Location: Hannover
Occupation: Informatikstudent (d'uh)
Zerschmetterling
Date of registration: Aug 31st 2003
Location: Hannover
Occupation: Informatikstudent (d'uh)
Source code |
|
1 2 3 4 5 6 7 8 |
for i in * do zeile`grep -m 1 -n "# (c) SRA" $i | cut -d ":" -f 1` zeile`grep -m 1 -n "grep -m 1 -n" $i | cut -d ":" -f 1` if [ $zeile ] then if [ ! $zeile2 -a $zeile2=$zeile] #<-- um die Zeile gehts uns (...) |
This post has been edited 2 times, last edit by "hamena314" (Feb 17th 2008, 10:09pm)