IFS=$'\n'

Liste des GroupesRevenir à cu shell 
Sujet : IFS=$'\n'
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.unix.shell
Date : 13. Aug 2024, 10:26:41
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v9f5c1$3q99m$1@dont-email.me>
User-Agent : Pan/0.159 (Vovchansk; )
I like having spaces in file/directory names, but I avoid putting newlines
in them.

This plays havoc with the shell’s word-splitting rules, because the
default value for IFS is

    IFS=$' \t\n'

which means names with spaces in them get split into separate items,
triggering lots of errors about items not found (or the wrong items found/
created).

However, if you change this to

    IFS=$'\n'

then this can make things much more convenient (provided you can be sure
there are no newlines in your file names). For example, I can do

    ls -lt $(find . -type f -iname \*fred\*)

to search for all filenames containing “fred” in the hierarchy rooted at
the current directory, and display them in reverse chronological order.

Date Sujet#  Auteur
13 Aug 24 * IFS=$'\n'8Lawrence D'Oliveiro
13 Aug 24 `* Re: IFS=$'\n'7Helmut Waitzmann
13 Aug 24  `* Re: IFS=$'\n'6Ralf Damaschke
14 Aug 24   +- Re: IFS=$'\n'1Lawrence D'Oliveiro
14 Aug 24   `* Re: IFS=$'\n'4Christian Weisgerber
15 Aug 24    +* Re: IFS=$'\n'2Ralf Damaschke
15 Aug 24    i`- Re: IFS=$'\n'1Ed Morton
15 Aug 24    `- xargs -x (was: IFS=$'\n')1Geoff Clare

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal