Reputation: 667
I'm trying to name a file with the content of one variable doing this script
#!/bin/bash
IFS=$'\n'
file=mails.txt
lines=$(cat ${file})
for line in ${lines}; do
echo "'${line}'"
final=echo "'$line'" |sed -e 's/^\.\*\(.*\)\*\./\1/'
curl -XGET "https://google.es" > $final.'.txt'
sleep 2
done
IFS=""
exit ${?}
The content of mails.txt is something like:
.*john*.
.*peter*.
And when I do that I have the error ./testcur.sh line 7: .john*. :order not found
, the same with peter. How can I do to name the files john.txt and peter.txt
Upvotes: 0
Views: 30
Reputation: 525
You have three mistakes
#!/bin/bash
IFS=$'\n'
file=mails.txt
lines=$(cat ${file})
for line in ${lines}; do
echo "'${line}'"
final=$(echo "$line" | sed -e 's/^\.\*\(.*\)\*\./\1/')
curl -XGET "https://google.es" > ${final}'.txt'
sleep 2
done
IFS=""
exit ${?}
Upvotes: 1