Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have found your site brilliant. What makes it good are the people that contribute to the site..."

Geography

Where in the world do Tek-Tips members come from?

using curl with awk in command line/shell script

leopardysnow (Programmer)
19 Mar 12 17:32
I have a text file url.txt with urls one per line. Something like:
http://www.something.com/image1.jpg
http://www.something.com/image2.jpg
...

If I put the following command in command line or in a shell script it works fine:

CODE

cat urls.txt | awk '{ print $0}'
This simply prints out the content of urls.txt line by line

So now I want to go 'get' the images from the urls so I thought I could do something similarly with curl such as

CODE

cat urls.txt | awk '{ curl --remote-name $0 }'
but this isn't working.
What I thought this would do is substitue each url from url.txt in $0 so that I would be doing a

CODE

curl --remote-name http://www.something.com/image1.jpg
   and so on.
Any ideas how to use curl with awk and use a variable instead of hardcoded http value(since my urls are coming from a text file)? Thanks.
PumpgunMessiah (TechnicalUser)
19 Mar 12 18:12
You can use the "System" function to execute shell commands within AWK:

CODE

cat urls.txt | awk '{ system("curl --remote-name " $0 }'
Annihilannic (MIS)
19 Mar 12 18:46
I'd use xargs:

CODE

xargs -n1 curl --remote-name <url.txt

Annihilannic
tgmlify - code syntax highlighting for your tek-tips posts

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close