broken-link-checker
broken-link-checker copied to clipboard
[Feature Request] add excludelist as file
Currently you add excludes one by one with --exclude localhost --exclude example.com ect.
It would be very beneficial if you could reference a file having a list of excludes one by line like:
--exclude-file myfile.txt
An example of myfile.txt
example.com
www.example.com
subdomain.example.com
Benefit, the list would be easy maintainable while the command itself stays the same.
This is what I'm doing until we get this done :D
Create a file called exclusions.txt
youtube.com linkedin.com
I create a variable with the exclusions in the format that blc expects:
exclusions=$(sed 's/(.*)/--exclude \1/' exclusions.txt | tr -d \n)
This will create a variable containing: --exclude youtube.com --exclude linkedin.com
And then:
blc -rof ${exclusions} --filter-level 1 https://example.org
create a variable with the exclusions in the format that blc expects:
exclusions=$(sed 's/(.*)/--exclude \1/' exclusions.txt | tr -d \n)
~FYI my system (Ubuntu 19.04) didn't like the sed parameter \1/, so I ended up with:~
Forget all that. What it needed was -r and to replace (not delete) the newline:
exclusions=$(sed -r 's/(.*)/--exclude \1/' exclude.txt | tr '\n' ' ')
P.S. If you're using zsh, switch to bash for this.