9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: sirjofri <sirjofri+ml-9fans@sirjofri.de>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] How do you deal with newlines (line feed, LF, \n) in filenames?
Date: Sat, 10 Aug 2024 23:05:24 +0200 (GMT+02:00)	[thread overview]
Message-ID: <7269fa6d-af8d-47a4-869a-b7187a33ce37@sirjofri.de> (raw)
In-Reply-To: <17233228160.1d47.67930@composer.9fans.topicbox.com>

Hi,

having newlines in filenames is questionable. However, needing a newline is quite common. In rc, you don't encode the newline, you just use it:

echo here is my '
' newline.

It's quite common to define it as a variable for easier use, for example:

nl='
'
echo $nl
files=`$nl{ls}
echo $files(1)

(The example is not that useful, because the standard delimiters contain a newline character.)

Instead of find, I usually use walk, but I don't really know the syntax. In these rare situations I often find myself using walk | grep instead of looking up the flags.

Good luck finding a solution that works for you.

I think there was a doscussion some time ago to add quotes to ls output for situations like these.

sirjofri

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T11149f1f949593f5-M4a923f98af111ae0821055d2
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

  reply	other threads:[~2024-08-10 21:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-10 20:46 kalterdev
2024-08-10 21:05 ` sirjofri [this message]
2024-08-10 21:32 ` [9fans] " kalterdev
2024-08-10 21:48   ` sirjofri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7269fa6d-af8d-47a4-869a-b7187a33ce37@sirjofri.de \
    --to=sirjofri+ml-9fans@sirjofri.de \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).