I am using bash that when run downloads a file a verifies that there is data in it. What I am not able to do is have a user enter a date in any format they wish and have it converted to m-d-yyyy. Thank you :).
Bash
printf " Welcome to NGS analysis, checking for new files and creating a directory "
# verify new files
wget -q --user=xxxx --password=xxx --xxxxx \
https://www.xxxx.com/file
if [[ -s /home/cmccabe/file ]]; then
printf " What is the date to analyze : "
read id
date=$(date -d "$id" "+%m-%d-%Y") #convert to month-date-year
Welcome to NGS analysis, checking for new files and creating a directory What is the date to analyze : 2-9-2015
date: invalid date �2-9-2015�
You are on a good path.... date -d is pretty good of decoding things. But the format mm-dd-yyyy isn't one of them. However, the US style mm/dd/yyyy is interpreted ok.
Obviously there is some ambiguity depending on region and personal taste.
Maybe you should suggest the format? Maybe the ISO guys got it "right"? ISO 8601 - Wikipedia
If the file.txt has data in it then a folder with todays date (m-d-y) is created in the path listed but the syntax appears wrong. Thank you :).
printf " Welcome to NGS analysis, checking for new files and creating a directory "
# verify new files
wget -q --user=xxxx --password=xxx --xxxxx \
https://www.xxxx.com/file
now=$(date +"%m_%d_%Y")
mkdir /home/cmccabe/Desktop/NGS/API/$now &&
else
echo " no new files to analyze, goodbye "
exit 1
fi
line 12: syntax error near unexpected token `else'
/home/cmccabe/Desktop/medical_exome.sh: line 12: `else'
---------- Post updated at 03:07 PM ---------- Previous update was at 02:53 PM ----------