bash script for list files
Author Message
Posted : Wed, 03 December 2008 11:39:34
Subject : bash script for list files
Hello. I need an script that do a files list, I will explain: I have a list of include directories "include.txt" /etc /home /var I have a list of exclude directories "exclude.txt" /var/apt /var/cache I need do with find command list all files included in the directories in "include.txt" file and will exclude all files in the subdirectories of the exclude list to other list, for example "result.txt" Any help will be appreciated Kokolisso
thobbs
Posted : Wed, 03 December 2008 17:22:38
Subject : Re: bash script for list files
You could do it with a one-line [b]find[/b] for each base directory to be search. To exclude, you can use the [b]-path [i]dir[/i] -prune -o -print[/b] for each [b][i]dir[/i][/b] you want to exclude. Example: [code=xml]find /var -path /var/apt -prune -o -print -path /var/cache -prune -o -print[/code] This would handle the var search. If you want to do it in a script, all you have to do is pull and plug the directories: one find for each base directory and exlude all directories for every find.