Post AiukxjPXHSCFnUI5nU by neingeist@mastodon.social
 (DIR) More posts by neingeist@mastodon.social
 (DIR) Post #AimykAtHbgtDUso7TE by simontatham@hachyderm.io
       2024-06-10T10:34:08Z
       
       1 likes, 3 repeats
       
       'mkdir -p' lets you make a deeply nested subdirectory like a/b/c/d, making all the intermediate directories on the way to it. So if even 'a' doesn't exist, it'll make that, then a/b, etc.But you can also get it to make multiple _non_-nested directories, because it accepts '..' in the path and doesn't treat it specially:$ mkdir -p alpha/../beta/../gamma$ lsalpha  beta  gamma$
       
 (DIR) Post #Aimyos4gzXvIaXNq9g by PopeASDF@dobbs.town
       2024-06-10T15:42:51Z
       
       0 likes, 0 repeats
       
       @simontatham @vxo 30 years of Unix work, never thought to do it that way
       
 (DIR) Post #AiuiWS3xTL6CGZ3vX6 by Stellar@mk.absturztau.be
       2024-06-14T09:10:29.903Z
       
       1 likes, 0 repeats
       
       @simontatham@hachyderm.io thanks i will use this for evil
       
 (DIR) Post #AiukxjPXHSCFnUI5nU by neingeist@mastodon.social
       2024-06-13T12:19:07Z
       
       0 likes, 0 repeats
       
       @simontatham @scy this should have been CWed as "cursed shell commands" tbh
       
 (DIR) Post #AiukxkvTeBLCUqF7Ds by scy@chaos.social
       2024-06-13T12:21:12Z
       
       1 likes, 0 repeats
       
       @neingeist @simontatham you mean like this gem that can be used as a workaround if your sed doesn't have `-i`?{ rm file.txt; sed '…' > file.txt ; } < file.txt
       
 (DIR) Post #Aiukzd3HtSVueemzVA by mr64bit@p.mr64.net
       2024-06-14T09:45:35.309188Z
       
       0 likes, 0 repeats
       
       @simontatham neat trick, but makes more sense to have your shell do the expansion for you.`mkdir /some/long/prefix/{alpha,bravo,charlie}`
       
 (DIR) Post #Aj25oGtoVz5aEJDfqy by simontatham@hachyderm.io
       2024-06-10T11:31:38Z
       
       0 likes, 0 repeats
       
       @neijatolf I'm going to have to get better at leaving space in my toots to make it clear whether I'm suggesting a useful tip, or being amused by a weird edge case.This was a 'weird edge case' toot. It's not a helpful pro tip!Perhaps the worst effect of 'mkdir -p' permitting this syntax is that you can bamboozle other people's shell scripts into making unrelated directories as a side effect of their intended behaviour. I wonder if there are any actual security holes arising from that.
       
 (DIR) Post #Aj25oI0aOI6HfbOb32 by Professor_Stevens@mastodon.gamedev.place
       2024-06-10T11:48:47Z
       
       1 likes, 1 repeats
       
       @simontatham @neijatolf In social media, all ambiguity is resolved in favor of whatever interpretation is most malevolent.