Date: Mon, 19 Oct 2020 07:22:43 +0200 From: Ralf Mardorf <ralf-mardorf@riseup.net> To: freebsd-questions@freebsd.org Subject: Re: sh scripting question Message-ID: <20201019072243.483c689e@archlinux> In-Reply-To: <20201018144327254822114@bob.proulx.com> References: <d50ba2c9-617f-6842-ef89-f5933be8f8b3@hotmail.com> <DB8PR06MB64427D88E17F02711EE657A3F6030@DB8PR06MB6442.eurprd06.prod.outlook.com> <20201016113408.16d58d68@archlinux> <DB8PR06MB644292D3C0309B5DADADF69BF6030@DB8PR06MB6442.eurprd06.prod.outlook.com> <24457.35680.223661.203846@jerusalem.litteratus.org> <444kmtudmy.fsf@be-well.ilk.org> <20201018144327254822114@bob.proulx.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 18 Oct 2020 14:37:55 -0600, Bob Proulx wrote: >And yet just the same the shell does handle whitespace and arbitrary >characters in file names easily. > > while IFS= read -r line; do > printf "|%s|\n" "$line" > done < file1 This just reads the file names from a file with a list of file names, now it depends what a user wants to do with those file names. Assuming it is intended to edit those file names depending on filter rules, the script could become very clumsy. The input file names might be "my_fine_stereo_song_named_my_cat_your_dog.wav" "fine_stereo_song_from_your_aunt_called_my_bird_your_bee.wav" and similar. The script should depending on filter rules, process those files and generate new files names "my_odd_stereo_song_left_channel_named_my_cat_your_dog.wav" "my_odd_stereo_song_right_channel_named_my_cat_your_dog.wav" "your_aunts_wonderful_stereo_song_remixed_to_mono_named_my_bird_your_bee.wav" and similar. It's easier to care for a single word separator "_", then to care for arbitrary word separators " ", " *** ", ";", " ", " : " and alternatively CamelCase, too, each on arbitrary positions. Keep in mind, the script already needs to detect the composer mentioned somewhere in the file name etc.. If I would add arbitrary word separators to my already broken English, it would make my sentences much harder to understand. IfIWould ; add.arbitrary <> word seperators. ToMy.already : broken -English,it,would MakeMy. sentences much-HarderTo understand. >And I think everyone is in agreement that the filenames that were >chosen were not the file names that any Unix person would choose to >name their files. No disagreement there. The reason that we are in agreement is, that it is difficult to handle freakish file names. Often enough we note, that our first idea how to name paths and/or directories wasn't optimal, already without using freakish word separators or other odd ideas. On Sun, 18 Oct 2020 15:44:20 -0600, Bob Proulx wrote: >$ find . -type f -exec sh -c 'ls -ld "$@"' sh {} + When writing a script as a file, we do want to write the scripts readable. A script becomes unreadable, if it becomes one long line. Command line is another story.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201019072243.483c689e>