I'mI am working in a bash shell and I am trying to print only the line of the first occurrence of the string. For example, for the string 'auir', if I have the file myfile.txt and it contains:
123 asdf 4wirajw forauir somethingelse starcraft mylifeforauir auir something else tf.rzauir I want to output "forauir somethingelse"
So far, I use the command
sed -n '/auir/p' myfile.txt which gives me all the occurrences of this string. How can I only get the first line that 'auir' occurs on? It'd be great if it was just a single command or pipeline of commands.
Any insight is greatly appreciated.