I have several directories which contain hidden empty files. I need the name of these file names themselves, so I need to write the filenames to a txt file. My script looks like this:
cd /z/all_vendors/
x=`find vendors -perm 755`
for FILE in $x; do
ls -a $FILE >> locator.txt
done
However I get a permission denied error
How do I write these hidden file names to a directory?
EDITS the vendors directory has subdirectories in the following way
vendors/
|__000123
|__000204
|__000404
so x=`find vendors -perm 755` finds all subdirectories with certain permissions
Each of the 000xxx subdirectories have the following tree structure:
000xxx/
.
..
.kpypjn32rz6l
.66jwvo6x96sj
etc where the hidden files start with a dot
I need to write the names of the hidden files to a txt file for example 'kpypjn32rz6l'
cd /z/all_vendors/ && find vendors -name '.*' >> locator.txt? This is not an answer because although I think the command kinda matches the (not entirely clear) description, I'm not sure if this is what you want, because your code may runls -afor directories and non-directories. Is-perm 755your way to find directories maybe? Sorry, there is so much weirdness in the code, I am confused about your desired output. Maybe if you posted an example directory tree (from the commandtree, [edit] the question) and the desired output, we could fix your code so it generates the output you want. – Kamil Maciorowski Nov 05 '21 at 23:03-perm 755? Do you want to skip directories with other permissions? Or is this your (peculiar) way to pick all directories to iterate over them later? (6) The name of.kpypjn32rz6lis.kpypjn32rz6lbut you specifiedkpypjn32rz6l. Please confirm you want to remove the dot from the output. // I'm asking becausecd /z/all_vendors/ && find vendors -type f -name '.*' -exec basename -a -- {} + >> locator.txtis quite straightforward and I have my doubts regarding if you really need to complicate it. Isbasename -aavailable in your OS? – Kamil Maciorowski Nov 05 '21 at 23:41basename -ais available – Fnechz Nov 05 '21 at 23:45