I have a file of filenames for files in a certain directory. However, some of the file names may:
- Have spaces in the original filename replaced with underscores (so
directory/file with spacesbecomes
file_with_spacesin the input file)
- May not actually match a file in the directory
If I didn't have these two conditions, I'd use
cat inputfile | awk 'commands' to process apply the commands I want on the file. However, I would like for some way to catch filename not found errors and either:
- Try with different combinations of underscores being replaced with spaces until it finds a matching file
- Provide a list of files that had no matches, even after substituting spaces for underscores.
Is there a good way to do this? I suspect that some type of script will be needed (rather than a one-line command), but I am not yet familiar with shell scripting enough to think of the solution.