Predictive Hacks

How to Search for a String within Documents in Unix/Linux

Let’s see how we can get all documents that contain the word pandas somewhere in a directory under the current directory. We can use the grep command as follows:

grep -r pandas *

Now, if we want to search for a word, let’s say “pandas” within a particular file (“myscript.py“) we can run the command:

$ grep pandas myscript.py 

If we want to search for any words but “pandas” we can run:

$ grep -v pandas myscript.py 

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Python

Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.

Python

Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s