Deutsch   English   Français   Italiano  
<83a5hgad4i.fsf@helmutwaitzmann.news.arcor.de>

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

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Helmut Waitzmann <nn.throttle@xoxy.net>
Newsgroups: comp.unix.shell
Subject: Re: IFS=$'\n'
Date: Tue, 13 Aug 2024 13:14:21 +0200
Organization: A noiseless patient Spider
Lines: 54
Sender: Helmut Waitzmann <12f7e638@mail.de>
Message-ID: <83a5hgad4i.fsf@helmutwaitzmann.news.arcor.de>
References: <v9f5c1$3q99m$1@dont-email.me>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Date: Tue, 13 Aug 2024 13:14:28 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f7c9b9bcec49b0f9ca39587ab8c93f76";
	logging-data="4064294"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX185iwASsPxD0l10Of5S8E7uhGQkZM+7A8E="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:kCK94ESoMG2we8Uf29vja3wnZAM=
	sha1:NBkSoxfxsFyzlpHNtxgBHMh2eUU=
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mail-Copies-To: nobody
Bytes: 2755

 Lawrence D'Oliveiro <ldo@nz.invalid>:=20
> However, if you change this to=20
>
>
>     IFS=3D$'\n'
>
> then this can make things much more convenient (provided you can=20
> be sure there are no newlines in your file names). For example,=20
> I can do=20
>
>
>     ls -lt $(find . -type f -iname \*fred\*)
>
> to search for all filenames containing =E2=80=9Cfred=E2=80=9D in the hier=
archy=20
> rooted at the current directory, and display them in reverse=20
> chronological order.=20
>

 Even if one is sure there are no linefeeds in the file names a=20
 cautious design could do=20


   (
     IFS=3D$'\n' &&
     ls -lt -- $(find . -name \*$'\n'\* ! -prune -o \
     ! -name \*$'\n'\* -iname \*fred\* -type f -print
     )
   )


 That will work if there are really no linefeeds in file names.=C2=A0=20
 And if there inadvertently were any linefeeds in file names it=20
 would at least not list file names that don't match the=20
 =E2=80=9C\*fred\*=E2=80=9C file name pattern.=20


 But=C2=A0=E2=80=93 according to the new POSIX standard=20
 (<https://pubs.opengroup.org/onlinepubs/9799919799/utilities/find.html#top=
>=20
 and=20
 <https://pubs.opengroup.org/onlinepubs/9799919799/utilities/xargs.html#top=
>)=C2=A0=E2=80=93=20
 one can use =E2=80=9Cxargs=E2=80=9C to get rid of any linefeed trouble at =
all:=20


   find . -iname \*fred\* -type f -print0 |
   xargs -0 -r -x -- ls -lt --


 That will work with any file names, even those containing a=20
 linefeed character.=20