POSIX Shell Programming Challenge - Programming On Unix
Users browsing this thread: 3 Guest(s)
|
|||
Hi,
I thought it would be fun to have a small shell programming challenge on here. The challenge is to iterate over all the files in a directory and print their path, without looking at the internet for guidance. We will then try to come up with ways in which proposed solutions are incorrect. Here are the criteria:
Here's an example: Code: for f in test/*; do And some possible critiques:
Looking forwards to seeing what solutions and non-solutions y'all come up with 🤓 EDIT: The idea behind the challenge is to end up with a shell loop over all the file names in a directory; printing the file names is just an example use case. Imagine replacing "echo" with some shell function or anything else. Also, it's not important whether the file name is prefixed with the path to the directory or not, because adding or removing a path prefix is trivial and not the point of the challenge. |
|||