If i want to awk the below pattern in a file

Mobilenumber '91_987986787688899' was successful

I used the below code

awk '/Mobilenumber '91_987986787688899' was successful/ {print $0}' Log Filename

Though the log file has that sentence its not rendering any result.

I spent a while on this but was not successful... Please help


You can also use grep:

grep "91_987986787688899.*successful" file

Unless your file has a very strange format, you could also probably just do this:

awk '/91_987986787688899.*successful/' file

There is no need for print $0, it is implied.


Simply enclose your pattern in double quotes. In your case though, you'll want to escape $ to avoid variable interpolation by the shell:

awk "/Mobilenumer '91_987986787688899' was successful/ {print \$0}" your_file

You can also use sed whose default action is to print its pattern space:

sed "/Mobilenumer '91_987986787688899' was successful/" your_file   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.