first time on here, I apologize if I missed anything.
I am currently writing a script that searches through each folder and looks for a <filename>.vmdk
file, after of which I want to do ls -lah
on this file.
Here is my current code for the script.
#!/bin/bash
parse_dir () {
for file in ./*/[A-Za-z][!-flat][!-thin].vmdk; do
#echo "File Found: "${file//\ /\\ }
ls -lah "${file//\ /\\ }"
#vmkfstools -i "${file//\ /\\ }" -d thin "${file%.vmdk}-thin.vmdk"
#echo "New provisioned file: ${file%.vmdk}-thin.vmdk"
done
}
parse_dir
This script outputs all of the matched files like this:
ls: ./ABC\ Collector/ABC\ Collector.vmdk: No such file or directory
HOWEVER! If I manually type in ls -lah ./ABC\ Collector/ABC\ Collector.vmdk
this file exists just fine.
Am I missing something here?
"${file//\ /\\\ }"
- if you escape spaces as well, that's likels -lah "./ABC\ Collector/ABC\ Collector.vmdk"
– steeldriver Sep 16 '20 at 21:24ls
. Look at the code again – Chris Davies Sep 16 '20 at 21:45