![]() ![]() In english: capture each line as caputure group 1 (\\1) I don't want to accidentally execute arbitrary code. I do this because later I intend to execute ~/. using the source command and because I don't know for sure the whole format of File_1.txt. In english: if more than one match is found on the same line, replace them all Comment Out the Entire Script sed -i -E "s/^(.*)$/#\\1/" ~/.Ībove uses a regular expression to prefix every line of ~/. with a bash comment character ( #). In english: prefix all special characters with a backslash In english: capture any punctuation or special character as caputure group 1 (\\1) = match any character that is NOT a letter, digit or space.= match any character NOT in a specific list of characters.= match a character from a specific list of characters.The script pattern "s/(find)/(replace)/" specifically performs the pattern match. Sed can do a lot more than regular expression pattern matching. ![]() I don't know what other characters might have special meaning, but I want to escape them all with a backslash: sed -i -E "s/()/\\\\\\1/g" ~/. What I don't know is how much I don't know about bash. $() - idk what this does but i think it can execute code.Requires bash v4+ for associative arrays. Writes the name to Output_file if changed. To print to the terminal window: /path/to/compare.py Ĭompares name/value pairs in 2 files in the format name value\n. With a few extra lines, you can make it either print to an outputfile, or to the terminal, depending on if the outputfile is defined: Mismatch = for item in data1 if not item in data2] Return ĭata1 = readfile(file1) data2 = readfile(file2) Litteraly sticking to the question (file1, file2, outputfile with "has changed" message) the script below works.Ĭopy the script into an empty file, save it as compare.py, make it executable, run it by the command: /path/to/compare.py įile1 = sys.argv file2 = sys.argv outfile = sys.argv
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |