1

I'm trying to remove the text before the italian word "ANDATA" in the pdf file of a bus line. I'm using this

pdftotext "file.pdf" - | sed -r "s/^.*ANDATA//g"

but this doesn't work. It only removes the word "ANDATA". I also tried to remove all newlines, and then perform the operation

pdftotext "file.pdf" - sed -r "s/\s//g" | sed -r "s/^.*ANDATA//g"

No newlines, but it still doesn't work.

What should I do?

EDIT 2 The word ANDATA occurs more than one time in the text, but I want only to remove what's before the first occurence.

EDIT

input

PIAZZA OBERDAN - UNIVERSITA' - S.CILINO STR. NUOVA PER OPICINA - OPICINA VILLA CARSIA - CAMPO ROMANO - VILLA CARSIA L’orario è passibile di variazioni per esigenze contingenti TRIESTE TRASPORTI S.p.A. Via dei Lavoratori, 2 Numero Verde: 800-016675 LINEA 4 FERIALE LUNEDI' - VENERDI' ANDATA VILLA CARSIA OPICINA VIA CANTU' PIAZZA OBERDAN PIAZZA TOMMASEO PROSECCO DEVINCINA 5:10 5:15 | 5:35 | | 5:30 5:35 | 5:55 | | 6:00 6:05 | 6:25 | | 6:15 6:20 | 6:40 | | 6:30 6:35 | 6:55 | | 6:45 6:50 | 7:10 | | 6:55 7:00 | 7:20 | | 7:10 7:15 | 7:35 | | 7:20 7:25 | 7:45 | | 7:30 7:35 | 7:55 | | 7:45 7:50 | 8:10 | | 8:00 8:05 | 8:25 | | 8:25 8:30 | 8:50 | | 8:50 8:55 | 9:15 (etc..)

output (with my regex)

PIAZZA OBERDAN - UNIVERSITA' - S.CILINO STR. NUOVA PER OPICINA - OPICINA VILLA CARSIA - CAMPO ROMANO - VILLA CARSIA L’orario è passibile di variazioni per esigenze contingenti TRIESTE TRASPORTI S.p.A. Via dei Lavoratori, 2 Numero Verde: 800-016675 LINEA 4 FERIALE LUNEDI' - VENERDI' VILLA CARSIA OPICINA VIA CANTU' PIAZZA OBERDAN PIAZZA TOMMASEO PROSECCO DEVINCINA 5:10 5:15 | 5:35 | | 5:30 5:35 | 5:55 | | 6:00 6:05 | 6:25 | | 6:15 6:20 | 6:40 | | 6:30 6:35 | 6:55 | | 6:45 6:50 | 7:10 | | 6:55 7:00 | 7:20 | | 7:10 7:15 | 7:35 | | 7:20 7:25 | 7:45 | | 7:30 7:35 | 7:55 | | 7:45 7:50 | 8:10 | | 8:00 8:05 | 8:25 | | 8:25 8:30 | 8:50 | | 8:50 8:55 | 9:15 (etc)

EDIT 3

DESIRED OUTPUT

VILLA CARSIA OPICINA VIA CANTU' PIAZZA OBERDAN PIAZZA TOMMASEO PROSECCO DEVINCINA 5:10 5:15 | 5:35 | | 5:30 5:35 | 5:55 | | 6:00 6:05 | 6:25 | | 6:15 6:20 | 6:40 | | 6:30 6:35 | 6:55 | | 6:45 6:50 | 7:10 | | 6:55 7:00 | 7:20 | | 7:10 7:15 | 7:35 | | 7:20 7:25 | 7:45 | | 7:30 7:35 | 7:55 | | 7:45 7:50 | 8:10 | | 8:00 8:05 | 8:25 | | 8:25 8:30 | 8:50 | | 8:50 8:55 | 9:15 (etc..)
0

1 Answer 1

0

Try this command

pdftotext "file.pdf" -|tr -d '\n'|sed -r 's/^.*ANDATA/ANDATA/'

it will remove the text before the word ANDATA

8
  • this doesn't work unfortunately...
    – Andre99
    Dec 28, 2016 at 9:35
  • give as some sample input and desired output
    – Dababi
    Dec 28, 2016 at 9:37
  • and try this command pdftotext "file.pdf" - | sed -r 's/^[^.]*ANDATA/ANDATA/'
    – Dababi
    Dec 28, 2016 at 9:39
  • still nothing..
    – Andre99
    Dec 28, 2016 at 9:42
  • give as the desired output and not your output
    – Dababi
    Dec 28, 2016 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .