Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.unix.programmer Subject: Re: Long filenames in DOS/Windows and Unix/Linux Date: Tue, 03 Sep 2024 21:36:48 -0700 Organization: None to speak of Lines: 30 Message-ID: <8734mg11cv.fsf@nosuchdomain.example.com> References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <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> <87o7541ggd.fsf@nosuchdomain.example.com> <87bk141cw9.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 04 Sep 2024 06:36:48 +0200 (CEST) Injection-Info: dont-email.me; posting-host="0c8cc2609bc8d9fbbbb3d106ce45f413"; logging-data="3897102"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18c3eMjKS8qup+Fo+cOMiCE" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:d4Rip3hpXTBYJS7bXOok8WMuRmE= sha1:6jkPEyY3Beect8J75sX5UGLn1Fo= Xref: csiph.com comp.unix.programmer:16283 Lawrence D'Oliveiro writes: > On Tue, 03 Sep 2024 17:27:34 -0700, Keith Thompson wrote: >> Second attempt: >> >> IFS='\n' ; for file in * ; do cp -p $file $file.bak ; done >> >> but that leaves IFS set to its new value in my interactive shell. > > Which in my experience is no biggie. Perhaps. Honestly, I've never paid enough attention to IFS to have any confidence in doing anything other than leaving it alone. > Next step: what if you wanted to handle newlines in file names as well? Either `find ... -print0 | xargs -0 ...` or a quick Perl script. opendir my $DIR, '.' or die ".: $!\n"; foreach my $file(grep { $_ ne '.' and $_ ne '..' } readdir $DIR) { system 'cp', '-p', $file, "$file.bak"; # error checking omitted for now } closedir $DIR; (I'm not arguing that Perl is the best or only language for this; it just happens to be what I'm most familiar with.) -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */