Reputation: 37
I am considering creating a daily script to go through hundreds of Markdown files (on a Mac) and perform simple operations such as:
I was assuming a Python would be the best option but somebody told me that a bash script using grep
, sed
etc is the best solution in terms of speed, being able to scale up, portability etc. What is your expert advice?
Thanks!!
Upvotes: 1
Views: 696
Reputation: 15309
Depends on exactly what to replace, meaning how hard the "find" and "replace" operation are to represent -- complex logic should better be managed in a proper programming language like Python.
Complex date calculations are a bit awkward in bash
, but can be done. Python might be somewhat more readable here.
Speed: Likely not going to matter since you are I/O-limited, and only doing it once a day. But if it matters, Python would of course be slower.
Portability: Python would be portable to Windows, command line tools like sed
less so. sed
would produce shorter code though.
In conclusion, both options are totally appropriate.
Upvotes: 1