79337886

Date: 2025-01-08 03:18:34
Score: 0.5
Natty:
Report link

Frame challenge: I don't need to compare the two files, I can do sed shenanigans.

  1. Extract matching lines from master to have the entire line.
  2. Wrangle the lines to have just the path.
  3. Use sed grouping to copy the old path and filename, then build a sed command in place inside a new file.
  4. Execute the new file.

This means that the python snippet looks like:

commands = ['program finder.exe "flaggedfile" > list.txt'
           ,'sed "\#"`pwd`"#d" list.txt | sed "s/:.*//" > moved.txt'
           ,'program mover.exe moved.txt .'
           ,'grep -f moved.txt master.txt | grep -o "\/.*\.txt" | sed -r "s?^(.*/)(.*)?sed -i \\"s#\\1\\2#`pwd`/\\2#g\\" master.txt?g" > updatemaster.txt'
           ,'. ./updatemaster.txt'
           ]

I tested this and it does work. Thank you to everyone for your advice. I understand that I have weird constraints that I'm working with, and I'm sorry that I can't use python properly because of it.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: David Robie