-1

I have a (long) text file containing lines of 80digits each (without any separator). I would like to display the lines that have a "1" as the 70th digit and a "2" as the 71th digit.

For instance this line : "8130455.72 0.74653771 8130457.72 0.74653782 8130459.71 0.74653792152812 9143301"

What would be your best strategy to deal with this problem please ? I did try something like ^.{71}[11$] in regex but it doesn't work...

I am using the regex of Notepad++ but if necessary I can write a bash script in order to extract these columns.

Thanks !

Pierre
  • 5
  • 4
  • See https://regex101.com/r/WhrXS6/1 – Wiktor Stribiżew May 23 '22 at 09:22
  • What should _[11$]_ mean? If you want to match 12 it's `12` and nothing more. Also, if it's character nr 70, you need only 69 other characters before that, not 71. -> `^.{69}12` – Chrᴉz remembers Monica May 23 '22 at 09:25
  • 2
    No need for a regular expression. `awk 'substr($0, 70, 2) == "12"' yourfile` – Shawn May 23 '22 at 09:30
  • (1) `[11$]` matches a character which is either a `1` or a `$`. What are you going to do here (2) I don't know the regexp syntax understood by Notepad++, but the `{...}` operator is understood for instance by the ` -E` option of _grep_ or the `=~` operator of _bash_. (3) I don't understand what you mean by _extracting **those** columns_. – user1934428 May 23 '22 at 10:29
  • `grep -E "12.{8}$" yourfile` – ufopilot May 23 '22 at 12:47

0 Answers0