Reputation
335
Top tag
Next privilege 500 Rep.
Access review queues
Badges
2 8 20
Impact
~97k people reached

9h
answered Refer to a file under the same directory of a script found in $PATH
1d
comment Append something to each list in a file
Let us continue this discussion in chat.
1d
comment Append something to each list in a file
Short, sweet, and functional. I like it.
1d
comment Append something to each list in a file
The exact input is here. The exact output is here. Search for something new and another thing.
1d
comment Append something to each list in a file
There's an unescaped bracket in line 2: '\(.*[\)' should be '\(.*\[\)'. Other than that, it almost works. I should have mentioned the list names are repeated at the bottom of the file, which may be causing some weirdness - instead of list_foo[i++] = z;\n list_foo[i++] = 'another thing'; I'm seeing var list_foo_regx = new RegExp(list_foo.join("|"), "i");\n list_foo[i++] = 'another thing'; Could it be due to the underscore in the variable name?
1d
comment Append something to each list in a file
By the way, the condensed version has different parens at the beginning of the second line: if(/(list.)/) vs if(/list./). Does that affect anything?
1d
comment Append something to each list in a file
I think the only lines that would need to be modified in the case that list1 is actually GoodDomains, list2 is actually BadDomains, etc. are 5 /list./; and 16 if(/list./). Maybe something like ^\([^[]*\)\(\[.*\) from @don_crissti's answer to capture everything up to the open bracket?
1d
comment Append something to each list in a file
I take it file is lists.txt. How do the additional values get inserted?
1d
suggested rejected edit on Append something to each list in a file
1d
comment Append something to each list in a file
My brain just exploded into a million pieces.
1d
answered Append something to each list in a file
1d
comment Append something to each list in a file
@G-Man this solution can be abstracted. Please see my latest edit.
1d
comment Append something to each list in a file
@terdon please see my latest edit.
1d
revised Append something to each list in a file
added 1402 characters in body
1d
comment Append something to each list in a file
@terdon sorry, I thought I had included the pertinent parts of the script D:
1d
comment Append something to each list in a file
@terdon comments and variable declarations. You've identified part of the problem. See securemecca.com/Downloads/proxy_en.txt
1d
revised Append something to each list in a file
added 214 characters in body
1d
asked Append something to each list in a file
2d
comment How can I prepend and append to each member of an array?
Oh, so it is pure bash :)
2d
accepted How can I prepend and append to each member of an array?