I have, e.g., in the directory /etc/ files without extension and with extension
/etc/profile
/etc/profile.1
/etc/profile.2
and there is a directory given by the system containig some files:
/etc/profile.d/file1
/etc/profile.d/file2
/etc/profile.d/file3
In a script I would like to specify that ls lists all my profile* files but not the files in the directory which begins with the same name as my files.
If the dir name "/etc/profile.d/" will be listed is not important, but the files under this dir should not be listed.
This my wish is according to what the manpage says, that ls will only work recursively if the option "-R" is given.
I want to use ls because its sorting capabilities and because ls can show modification, access and creation times, etc.
Normaly I would use this command:
ls -la --time-style=long-iso /etc/profile*
but this not only shows my files, ls goes down into the directory /etc/profile.d and lists the files in this dir too.
I am interested in a general solution, not only for the given names in this example.
Regards
Anton_Wessel@t-online.de
-d
option? Fromman ls
: -d, --directory: list directories themselves, not their contents – steeldriver Sep 22 '22 at 16:19ls
. If you're just invoking it for user information, that's not a problem. – Toby Speight Sep 22 '22 at 17:09ls
in a script, that is just asking for trouble. See https://mywiki.wooledge.org/ParsingLs and Why *not* parse `ls` (and what to do instead)?. – terdon Sep 22 '22 at 17:42