Artificial intelligent assistant

How do I generate a list of the characters occurring before a certain character only in lines that contain another certain character using regex? I have a text file that looks like this: 407-OL? 408-2-OL? 408-OL? 418-het? 420-1 and 2- OL? 429-2-left unscored? 430-2-left both unscored? 431-1 and 2- Ri?? 436-1-just homozygote? 444-2-het? ins. both 456-2-ins 246 despite slight OL 456-1-ins 245 (weaker) 457-2-Ri? I want it to return the numbers on the left (before the dash), but only for lines that contain a question mark. In other words, I want this to be the output: 407 408 408 418 420 429 430 431 436 444 457

Probably easiest method: `cat some_file | grep '?' | cut -d'-' -f1`

* `cat somefile` => feed the contents of `some_file` into the pipe
* `grep '?'` => filter only lines containing a `?`
* `cut -d'-' -f1` => divide the string into fields with `-` as field separator, then print field #1

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy de2a94866e9cab899b035b68705485cc