I have a file with dates where i want the dates to change to the day of the week using bash. I did this by the following while statement:
while read p; do
date -d $p +%A
done <dates.txt
This works fine, but now i want the output of this statement in a file, say output.txt.
I tried
while read p; do
date -d $p +%A
done <dates.txt >output.txt
But this gives the error date: extra operand '+%A'
while IFS= read -r p; do date -d "$p" +%A; done > output.txtdates.txtin-between the code change? Please note double quotes around$pin KamilCuk's suggestion, that's generally important.