I have a method where I'm executing a curl command and it returns the result. I would like to pass arguments to this method but it isn't working.
commande_mine() {
local MY_OUTPUT=$(curl -X POST \
http://localhost:5000/myapp \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"filepath": "$1"
}')
echo $MY_OUTPUT
}
for f in "/Users/anthony/my files"/*
do
commande_mine $f >> test.txt
break # break first time until everything works as expected
done
How can I use the $f
parameter passed into the function inside the curl
command?