i did try command:

folder_tmp=~/name-x-tmp/   #this is worked
echo -n "url: " && read -e url   #this is worked
wget -P $folder_tmp -O 1.txt $url  #this is not worked!!
exit 1

what is my wrong? maybe is not worked toghter -P and -O, right?


It's not explicitly stated in the man page but -O effectively preempts everything else in terms of the path to the output file. To achieve what you want try

mkdir -p "$folder_tmp"
wget -O "$folder_tmp/1.txt" "$url"
  • Be sure to quote your variables! – Eric Renouf Nov 20 '15 at 16:39
  • Fixed. It was a quick copy/paste job and I didn't proof it well enough ;) Thanks for catching it – David King Nov 20 '15 at 16:40
  • > out error: /home/user/name-x-tmp//1.txt: File o directory did not existent – manuel Nov 20 '15 at 16:55
  • 1
    Does the directory /home/user/name-x-temp exist? You'll need to make sure the directory exists first. – David King Nov 20 '15 at 16:56
  • instead with -P will create automatic if directory not exist.. – manuel Nov 20 '15 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.