EDIT: What looked like the file actually isn't, and what I want isn't straightforward.
I know that a directory is actually a specialised file, e.g. ~/Pictures is actually a file containing details about what's inside the Pictures folder.
I can view the folder-file directly using vim:
vim gives a warning message, "~/Pictures/" Illegal file name, but still allows me to view it.
(Presumably, I would lose data to edit the file, so I won't attempt to do that! Actually, I tried this in a VM to see what would happen, and the system wouldn't let me directly modify it, at least not with Bash or vim.)
I'm curious about how to read that file directly from a Bash script. I tried using this:
Code:
while read ENTRY
do
printf '%s\n' "${ENTRY}"
done <${HOME}/Pictures
But this doesn't work, because Bash (correctly) returns the error that Pictures is a directory. Likewise, I can't use cat to display the folder-file:
Code:
$ cat ~/Pictures
cat: /home/paddy/Pictures: Is a directory
Is there some command that I can use within a script to directly read the folder-file?
I know that this is an odd request. I'm asking out of sheer curiosity, not because I need it.
Thank you 😊