Skip to main content

Timeline for is 'sed' thread safe

Current License: CC BY-SA 4.0

10 events
when toggle format what by license comment
Mar 15, 2024 at 13:18 history edited João CC BY-SA 4.0
Contribution from comment, plus context improvement to avoid misunderstandings
Mar 15, 2024 at 13:09 comment added João Thanks, that is just example, not real code. Flock is all about controlling access to shared resources, same file. The sed on the same file is the not so great practice. In my specific case working on adding gnu parallel on existing large shell script code base. Using flock to control the concurrent access on operation worked great.
Mar 14, 2024 at 11:28 comment added Kusalananda Would it not potentially be problematic to use flock with the same file you use with sed? It more common to use flock with a separate file. After all, you are not locking the file, you are locking the operation. Also, your code needs double quoting of all shell variable expansions.
Mar 14, 2024 at 11:01 history edited João CC BY-SA 4.0
added 11 characters in body
Mar 14, 2024 at 6:05 history edited João CC BY-SA 4.0
added 60 characters in body
Mar 14, 2024 at 6:02 comment added João Hello, typing back here I missed typing the first argument of flock in the example. That was not what I implemented in my situations with a concrete sed -i (of an application level data corruption issue). Fixed my reply. Hope now it is correct and useful for similar situations. Thanks for the feedback.
Mar 14, 2024 at 5:49 history edited João CC BY-SA 4.0
added 12 characters in body
Mar 13, 2024 at 17:28 comment added tink The way I read your example you locked a file called sed in the current directory .... not sure what the rest of the command will do.
S Mar 13, 2024 at 16:17 review First answers
Mar 14, 2024 at 11:09
S Mar 13, 2024 at 16:17 history answered João CC BY-SA 4.0