Deutsch   English   Français   Italiano  
<vb90s2$3o2de$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Wed, 4 Sep 2024 07:05:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <vb90s2$3o2de$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
	<ubg6o7$3jrsn$1@news.xmission.com> <ubg853$2ssj8$1@dont-email.me>
	<ubg8a8$2t20l$1@dont-email.me> <vaubbo$1d324$1@news.xmission.com>
	<vauknd$uvji$1@dont-email.me> <20240903084440.0000663d@gmail.com>
	<20240903103327.395@kylheku.com> <20240903113937.000008a3@gmail.com>
	<20240903130000.933@kylheku.com> <20240903132547.00000656@gmail.com>
	<87seug1iyj.fsf@nosuchdomain.example.com> <vb81vo$3g6hb$6@dont-email.me>
	<87o7541ggd.fsf@nosuchdomain.example.com> <vb87jr$3h6uk$1@dont-email.me>
	<87bk141cw9.fsf@nosuchdomain.example.com> <vb8ahn$3hhg4$2@dont-email.me>
	<8734mg11cv.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 04 Sep 2024 09:05:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="176f5fbfb5d1157be6fd816dae78eee8";
	logging-data="3934638"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19C3Tkzkye1U8eXviIuDxOu"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:l+OEp9cMYbgd0OeeDl6LKB89e/A=
Bytes: 2522

On Tue, 03 Sep 2024 21:36:48 -0700, Keith Thompson wrote:

> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>
>> Next step: what if you wanted to handle newlines in file names as well?
> 
> Either `find ... -print0 | xargs -0 ...` or a quick Perl script.

Sure, it’s much easier in Perl or Python or some other such programming-
oriented (as opposed to command-oriented) language. But it can be done in 
Bash.

The thing is, while find is handy for getting the matching file names, 
xargs is not always the most convenient way of processing them. You often 
just want to be able to do “for f in «filenames»; do «whatever» done”, 
e.g.:

    collect_expand «wildcard» found_filenames
    for f in "${found_filenames[@]}"; do
        echo "found" $(printf %q "$f")
    done

That “collect_expand” is a Bash function. Do you want to figure out how to 
write it, before I post my solution? ;)