Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,

I have to write a unix script and I am really not familiar with it and need help.

I have a root directory, inside it I have a lot of other directories.
Each directory contains txt files.
I have to go through all the directories and all the files.
If a file contains the phrase "file information" I want to keep the file. If the file does not contain it, I want to delete the file.
Then, If all the files of a directory have been deleted, and the directory is empty, I want to delete the directory.

How can I write a script like that?

Thanks
Posted

1 solution

Your task is fairly articulated. Since you are not an expert on shell scripting I suggest you the divide, Google et impera approach: for instance, you could start searching for how to perform a recursive find in shell script[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900