Issue
I have this file
1.1some text
2.some text
1.line I need
How can I print only the first line in a file that start with "1." followed by any character except a number? I expect this:
1.line I need
my code is this
q=$(grep "^[0-9].[a-z]" "file")
echo $q
Thank you
Solution
With your shown samples, please try following grep
code. Simple explanation would be: Using grep
's m1
option to print only first match and exit from program then in main program mentioning regex to match lines that start from 1.
followed by a non-digit character, if match is found then print the line.
grep -m1 '^1\.[^0-9]' Input_file
Answered By - RavinderSingh13 Answer Checked By - Mildred Charles (WPSolving Admin)