10.08.2024 23:32:48 kalter...@gmail.com: > Thank you for your reply. I was referring to having newlines specifically in > filenames. Sometimes it's not one's own fault that filenames have them.
Sure, that can happen. I just wonder who would do that on any system. > I wasn't really speaking about the way to represent a newline in rc, although > thanks for details on that problem. My problem is to parse command output > that has a newline in a filename. > > On my system, find(1) just prints the newline as is. So if the output looks > like this: > > a > b > > It is actually possible that it means one "a\n" file, not file "a" and file > "b". I think in this case it would be either two files ("a" and "b") or one file ("a\nb") because otherwise it would look like this: a b > Some commands, including ls(1) from plan9port, support quoting such files. > But then the problem is how to parse them. Yeah, that's more complicated then. I don't think we have standard tools to deal with that situation out of the box yet. That is, if you're lucky enough to have an ls, walk or find that can quote them, you can parse them using different tools (awk, sed, or build them yourself in C). It would probably easier to circumvent this by getting file by file, for example using some dirstat counterpart or maybe even a for loop (but I think for loops also work with command output). Maybe someone else can help you find a more pleasing solution, sorry. sirjofri ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T11149f1f949593f5-M57ab58e7079320469579f89b Delivery options: https://9fans.topicbox.com/groups/9fans/subscription