wget output file names


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting wget output file names
# 8  
Old 07-17-2012
Now,

I have downloaded as suggested by Alister. My files are named like this

Code:
index.html?acc=OSR765454&file=filename1.gz
index.html?acc=OBR765454&file=filename111.gz
index.html?acc=ORS765454&file=filename1111.gz
index.html?acc=OST76454&file=filename11111.gz
index.html?acc=OS5454&file=filename1111111.gz

I was using the following command

Code:
mv index.html?acc=OSR765454&file=filename1.gz filename1.gz

The error I see is the following

Code:
[1] 14709
mv: missing destination file operand after `index.html?acc=OSR765454'
Try `mv --help' for more information.
-bash: filename1.gz: command not found
[1]+  Exit 1                  mv index.html?acc=OSR765454

Any thoughts?
# 9  
Old 07-17-2012
The & is a special character to the shell. The command is cut off at that point. So the shell takes everything before it as a command to run in the background.
Code:
[1]+  Exit 1                  mv index.html?acc=OSR765454Exit 11

And then afterwards will run the following command:
Code:
file=filename1.gz filename1.gz

Which creates a variable named file with a value of filename1.gz intended for the environment of the command filename1.gz (which of course doesn't exist and so you get that command not found error).

To fix that mv command, quote any arguments with shell metacharacters. In your example, aside from the &, the ? is also special.

Quote:
Originally Posted by jacobs.smith
I have downloaded as suggested by Alister.
Don't blame this on me. Smilie I never suggested doing this. I merely mentioned that you could try using rename if you insisted on using wget -i. I suggested keeping it simple with scott's solution. I don't understand why you don't like that simple while-loop. Did you run it? If so, was it unacceptably slow? Did it give you an erroneous result?

Regards,
Alister

Last edited by alister; 07-17-2012 at 11:23 AM..
# 10  
Old 07-17-2012
Alister,

I do love Scott's solution, but the point is after I get a bunch of those wget commands, I have to run them individually.

But, anyways I used the following command

Code:
mv index.html'?'acc=OSR765454'&'file=filename1.gz filename1.gz

And it works like a charm. Do you have a simple solution to do the above task in batch on all the files in the directory using rename? Because, I can't write the mv command for all those files in my directory. They are around 400 files. And the OSR number after acc= is varying. Can you suggest me something using sed and rename or sed and mv?

Thanks for ur time.

Last edited by jacobs.smith; 07-17-2012 at 11:22 AM.. Reason: forgot code tags
# 11  
Old 07-17-2012
Quote:
Originally Posted by jacobs.smith
I do love Scott's solution, but the point is after I get a bunch of those wget commands, I have to run them individually.
Why manually? In your original post you stated that you had the list of urls in a file. Is that not the case? Are you not now using that file as an option-argument thusly:
Quote:
Originally Posted by jacobs.smith
I am using this command
Code:
wget -i input.txt

If so, just use this instead (I took the liberty of adding -r and quotes to scott's code):
Quote:
Originally Posted by Scott
Code:
while read -r URL; do
  wget "$URL" -O "${URL##*=}"
done < input.txt

It's just as automated.

Or have I missed something?

Regards,
Alister
# 12  
Old 07-17-2012
Alister,

You missed a point.

I did check my output files after editing the input.txt to the following

Code:
index.html?acc=OSR765454&file=filename1.gz -O filename1.gz
index.html?acc=OBR765454&file=filename111.gz -O filename111.gz
.....

This input.txt has to be given to the
Quote:
wget -i
command.

I did that and all I see is a single output file instead of one. If all the 5 file sizes together is 10GB. I see a single file filename1.gz to be 10GB.

Hope you got my point.
# 13  
Old 07-17-2012
Quote:
Originally Posted by jacobs.smith
You missed a point.

I did check my output files after editing the input.txt to the following

Code:
index.html?acc=OSR765454&file=filename1.gz -O filename1.gz
index.html?acc=OBR765454&file=filename111.gz -O filename111.gz
.....

Scott's solution does not use -i and is intended to work with the input.txt as initially specified:
Quote:
Originally Posted by jacobs.smith
Hi,
I have a list of urls in my input.txt file like this

input.txt

Code:
http://unix.com/index.html?acc=OSR765454&file=filename1.gz
http://unix.com/index.html?acc=OBR765454&file=filename111.gz
http://unix.com/index.html?acc=ORS765454&file=filename1111.gz
http://unix.com/index.html?acc=OST76454&file=filename11111.gz
http://unix.com/index.html?acc=OS5454&file=filename1111111.gz

Did you try his while-loop with that input data? It should work and no file renaming should need to be done.

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to list files names and sizes in a directory and output result to the file?

Hi , I'm trying to list the files and output is written to a file. But when I execute the command , the output file is being listed. How to exclude it ? /tmp file1.txt file2.txt ls -ltr |grep -v '-' | awk print {$9, $5} > output.txt cat output.txt file1.txt file2.txt output.txt (8 Replies)
Discussion started by: etldeveloper
8 Replies

2. Shell Programming and Scripting

Print the output with different file names

I have a python script that gives output called test.png. By using the following command I run the script every 2 seconds. What is the easiest way to save the output as follows ( test.png (1st output), tes1.png (second output), tes2.png ....) Command I i use while sleep 2; do python... (1 Reply)
Discussion started by: quincyjones
1 Replies

3. Shell Programming and Scripting

Wget - working in browser but cannot download from wget

Hi, I need to download a zip file from my the below US govt link. https://www.sam.gov/SAMPortal/extractfiledownload?role=WW&version=SAM&filename=SAM_PUBLIC_MONTHLY_20160207.ZIP I only have wget utility installed on the server. When I use the below command, I am getting error 403... (2 Replies)
Discussion started by: Prasannag87
2 Replies

4. Shell Programming and Scripting

Custom wget output

The below hides the messy commands of wget #!/bin/bash cd 'C:\Users\cmccabe\Desktop\wget' wget -O getCSV.txt http://172.24.188.113/data/getCSV.csv progressfilt () { local flag=false c count cr=$'\r' nl=$'\n' while IFS='' read -d '' -rn 1 c do if $flag ... (5 Replies)
Discussion started by: cmccabe
5 Replies

5. Shell Programming and Scripting

Exclude certain file names while selectingData files coming in different names in a file name called

Data files coming in different names in a file name called process.txt. 1. shipments_yyyymmdd.gz 2 Order_yyyymmdd.gz 3. Invoice_yyyymmdd.gz 4. globalorder_yyyymmdd.gz The process needs to discard all the below files and only process two of the 4 file names available ... (1 Reply)
Discussion started by: dsravanam
1 Replies

6. Shell Programming and Scripting

Encapsulating output of CURL and/or WGET

i use curl and wget quite often. i set up alarms on their output. for instance, i would run a "wget" on a url and then search for certain strings within the output given by the "wget". the problem is, i cant get the entire output or response of my wget/curl command to show up correctly in... (3 Replies)
Discussion started by: SkySmart
3 Replies

7. Shell Programming and Scripting

ery weird wget/curl output - what should I do?

Hi, I'm trying to write a script to download RedHat's errata digest. It comes in a txt.gz format, and i can get it easily with firefox. HOWEVER: output is VERY strange when donwloading it in a script. It seems I'm getting a file of the same size - but partially text and partly binary! It... (5 Replies)
Discussion started by: jstilby
5 Replies

8. Shell Programming and Scripting

Searching for file names in a directory while ignoring certain file names

Sun Solaris Unix Question Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Discussion started by: 2reperry
2 Replies

9. Shell Programming and Scripting

download a particular file using wget

Hi All I want to download srs8.3.0.1.standard.linux24_EM64T.tar.gz file from the following website : http://downloads.biowisdomsrs.com/srs83_dist/ But this website contains lots of zipped files I want to download the above file only discarding other zipped files. When I am trying the... (1 Reply)
Discussion started by: alphasahoo
1 Replies

10. UNIX for Dummies Questions & Answers

wget output question

Hello there, İ want to ask a very simple question. I want to read the output messages of wget both in terminal and also put them into a text file. i know that by using -o flag, i can log the messages into a text file but then i won't be able to see them on terminal. I'd appreciate any help... (1 Reply)
Discussion started by: sertansenturk
1 Replies
Login or Register to Ask a Question