ich brauch eure hilfe.. ich habe folgende Datei:
Code: Alles auswählen
#P
...
....
....
#P
----
---
----
#P
:::::
:::::
::::
SChonmal danke für eure hilfe..
Code: Alles auswählen
#P
...
....
....
#P
----
---
----
#P
:::::
:::::
::::
Code: Alles auswählen
#!/bin/sh
fileno=0
while read line
do
if [ "${line}" = "#P" ]
then
fileno=$((fileno+1))
printf "" > output_${fileno}.txt
fi
echo "${line}" >> output_${fileno}.txt
done < input.txt
Code: Alles auswählen
csplit -z filename '/#P/' '{*}'
Code: Alles auswählen
sed -i '/#P/d' x*
Code: Alles auswählen
$ awk 'BEGIN{RS="#P\n";ORS=""}{print($0)>i++}' archive
$ ls
0 1 2 3 archive
$ awk '{print(FILENAME": "$0)}' * # Ausgabe der Dateien mit deren Namen
1: file0
1: foo
2: file1
2: bar
3: file2
3: baz
archive: #P
archive: file0
archive: foo
archive: #P
archive: file1
archive: bar
archive: #P
archive: file2
archive: baz
$
Code: Alles auswählen
$ awk 'BEGIN{RS="#P\n";ORS=""}i++{print($0)>(i-1)}' archive
If universal surveillance were the answer, lots of us would have moved to the former East Germany. If surveillance cameras were the answer, camera-happy London, with something like 500,000 of them at a cost of $700 million, would be the safest city on the planet.
—Bruce Schneier