Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to check out the look command. It’s a command that allows you to easily pick out lines that begin with a given string from a file that you specify. The syntax is easy. You type “look” followed by the string you’re looking for and then the file name (find this in that).
And, if you couldn’t quite remember his name, you might try “look A” or, to make your request case-insensitive, add -f.
If the string you are looking for contains blanks or quotes, you need to enclose it in quotes. Here are some examples:
The look command only matches beginnings of lines and doesn’t work with wild cards. It’s limited, but the syntax is nice and simple. For more complex searches, you’re better off using grep which isn’t limited to the beginnings of lines and has a lot more options.
That’s your Linux tip for the look command.
If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.
previous post