Question: Please help me write a short Python script for Unix that will do the following: It will ask the user to enter a keyword and

Please help me write a short Python script for Unix that will do the following:

It will ask the user to enter a keyword and then it will find all of the .TXT files in the current directory that are contain that keyword inside the file (for example I have a file named fruit.txt that contains the keyword "apple" and I want to list all the files that contain "apple"), then put them in a new directory that we will declare from the command line. Then it will print the names of all the matching files it found and the total number of files.

Sample Output:

Me: ./script.dat MyNewDirectory

Please choose a topic

Me: Apples

OK, we found these files:

Fruit.txt

AListOfMyFavoriteFruits.txt

We copied 2 files to MyNewDirectory.

Any help is appreciated. Please use GREP.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!