Commit 0e143cb7 authored by John Delaney's avatar John Delaney Committed by Commit Bot

Fix awk script in filter list generation readme

Writing a file inplace does not work within an awk script. This CL
modifies the recommended script to write awk output to a temp file and
move it back to the original.

Change-Id: Ibc0e43d8b549a818fce2f4d48c557915275314eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090034
Commit-Queue: John Delaney <johnidel@chromium.org>
Reviewed-by: default avatarJosh Karlin <jkarlin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748298}
parent ade55632
...@@ -91,7 +91,7 @@ An example using [EasyList](https://easylist.to/easylist/easylist.txt) follows: ...@@ -91,7 +91,7 @@ An example using [EasyList](https://easylist.to/easylist/easylist.txt) follows:
Appends whitelist rules and also deduplicates rules which only differ by their set of affected domains. Appends whitelist rules and also deduplicates rules which only differ by their set of affected domains.
```sh ```sh
1. grep ^@@ easylist.txt >> smaller_list.txt 1. grep ^@@ easylist.txt >> smaller_list.txt
2. awk -F,domain= '{ if(!length($2)) table[$1] = ""; else table[$1 FS] = length(table[$1 FS]) ? table[$1 FS] "|" $2 : $2; } END{ for (key in table) print key table[key] }' smaller_list.txt > smaller_list.txt 2. awk -F,domain= '{ if(!length($2)) table[$1] = ""; else table[$1 FS] = length(table[$1 FS]) ? table[$1 FS] "|" $2 : $2; } END{ for (key in table) print key table[key] }' smaller_list.txt > smaller_list_deduped.tmp && mv smaller_test_deduped.tmp smaller_list.txt
3. sort smaller_list.txt | uniq > final_list.txt 3. sort smaller_list.txt | uniq > final_list.txt
``` ```
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment