brokenman wrote:Code: Select all
mkdir -p /tmp/play/"path with"/spaces
touch /tmp/play/path\ with/spaces/file.txt
find /tmp/play -name "file*" | xargs -n1 -i rm {}
Indeed that works, usually lazy me just fires up mc instead, that one is usually able to remove even the weirdest of files. Like a file or folder called "*" (without the ", or with the "), or files with Carriage return in them, many scripts file name handling fail due to assuming a line they find is always a file name, never thinking of the possibility that a filename can contain more than one line.
And all such names are valid UNIX file names that can derail badly written scripts or programs.
There is only one character that cannot be part of any file name or folder: The Null Character, due to C being the core of UNIX and Linux, history wise and the Null character being a divider of data entities for C.
When one wants a failsafe way in handling filenames, use a way to have them separated by only NULL and not assume anything else what characters they can or cannot have.
___________________________________________
Bogomips wrote:^ Such a precise answer, that haven't a clue which issue is being addressed.
We did encounter creating weird file names, but only as a by product. But @all, please look at this post where I praise donald for finally finding a solution and that at times are less complex, less formal approach is the better one:
http://forum.porteus.org/viewtopic.php? ... 698#p44267
...
I also will include a new part of that script, cause usually I create the folder in /tmp by the naming convention and then xzm2dir the last working version of the settings module into that (to have all older settings and data in it), and then I would run the script to be in the right folders for only copy files that need or should be saved and leave out all others I want to discard.
But
at times it happens I want to copy new content into the target folder, but forgot that I have so far not yet created the target folder, and also
not yet did the xzm2dir into that very folder, so the
mc still starts even when one of the panels could not open in the intended path since that path in non existent.
Instead of still starting mc with invalid folder my script should instead check if the "wildcard and spaces" path is a valid path, as in: run
# file "wildcard and spaces"
and look if we get as result ": directory" at the end as we need to get, since only then mc can be launched in the way it is intended...
(Or check if both paths are valid)