3
I need to extract data from a text and I’m trying to do this using grep. But the way to make use of regular expressions with this command is quite different from what is usually done in Ruby or Javascript, and I’m not being able to do what I need. In the following text:
Judicial Notebook of the Regional Labor Court of the 1st Region
ELECTRONIC JOURNAL OF LABOR JUSTICE JUDICIARY
Nº1697/2015
FEDERATIVE REPUBLIC OF BRAZIL
Release date: Wednesday, 01 April 2015.
Regional Labour Court of the 1st Region
I just need to get the number that can be seen on the third line. This number will later be used to make a request to a webservice. I tried with grep as follows:
pdftotext Diario_1697_1_1_4_2015.pdf -f 1 -l 1 - | grep -o /Nº(\d+\/\d+)/
I take the first page of a pdf file, convert it to txt and step to the grep command to extract the information. But that doesn’t work at all. Someone knows the right way to do it with grep or some other bash command?
@JJOAO: It works on Bash but not on my default shell which is Fish. The only redundant backslash was the
/
– hugomg