I run fish
shell and it gives an exception when I try to remove a file which is not found. I have the following script:
#!/usr/bin/fish
set files "/tmp/*.xlsx"
rm -f "$files"
echo "$files"
set tmpfile (mktemp -u).xlsx
curl http://localhost:18085/myService -o "$tmpfile" -s
xdg-open "$tmpfile"
When I run it like this than the files
variable has a complete list of all the patterns. But if one of them cannot be deleted (e.g. still opened) - none would be delete.
I have two questions:
- What is the best way to delete the files?
- Since I'm developing sometimes the file isn't downloaded by the
curl
. How to check and only open if the download was successful? (check if exists or check if file size >0 or??)
(mktemp -u).xlsx
you mean$(mktemp -u).xlsx