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?


1 Answer 1


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! Commented Nov 20, 2015 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
    Commented Nov 20, 2015 at 16:40
  • > out error: /home/user/name-x-tmp//1.txt: File o directory did not existent
    – manuel
    Commented Nov 20, 2015 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
    Commented Nov 20, 2015 at 16:56
  • instead with -P will create automatic if directory not exist..
    – manuel
    Commented Nov 20, 2015 at 16:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .