Call awk script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Call awk script
# 1  
Old 10-07-2014
Call awk script

The below awk script (loop.awk) is in the cygwin home directory. I do a cd to the directory where the Sources.txt is (where I would like the data output in), but the script does not run:
Code:
 echo loop | ./loop.awk

loop.awk

Code:
 #!/bin/awk -f
BEGIN {} 
cat Sources.txt | while read a
do
//generate a uniquefilename//
wget ${a} >  //uniquefilename//
done
END {}

I am new to awk and trying to learn. Thank you in advance Smilie.

Basically, the code connects to each website and downloads the source code for each in a separate output file.
# 2  
Old 10-07-2014
Code:
$ awk '{print "wget",$0}' Sources.txt | sh

For unique urls you can do like this

Code:
$ awk '!a[$0]++{print "wget",$0}' Sources.txt | sh

Or else try just

Code:
$ wget -i Sources.txt

# 3  
Old 10-07-2014
Code:
 
awk '!a[$0]++{print "wget",$0}' html.txt | sh
--2014-10-07 13:25:34-- https://www.genedx.com/test-catalog/available-tests/edar-gene-sequencing/
Resolving www.genedx.com (www.genedx.com)... 104.130.145.205
Connecting to www.genedx.com (www.genedx.com)|104.130.145.205|:443... connected.
ERROR: The certificate of `www.genedx.com' is not trusted.
ERROR: The certificate of `www.genedx.com' hasn't got a known issuer.

I am not sure how to add this certificate in chrome. I am going to be downloading from multiple sites does a unique certificate need to be used for each or is there a better way? Thanks.
# 4  
Old 10-07-2014
Quote:
Originally Posted by cmccabe
T
Code:
 #!/bin/awk -f
BEGIN {} 
cat Sources.txt | while read a
do
//generate a uniquefilename//
wget ${a} >  //uniquefilename//
done
END {}

.
Hey that's NOT an awk script, rather just an horrible mix of 1 awk line with shell scriptSmilie

Last edited by blastit.fr; 10-07-2014 at 05:31 PM.. Reason: typo
# 5  
Old 10-07-2014
Quote:
Originally Posted by blastit.fr
Hey that's NOT an awk script, rather just an horrible mix of 1 awk line with shell scriptSmilie
@blastif.fr
Out of curiosity, what shell do you know that uses the following syntax?
//generate a uniquefilename// as a comment or external command and then as a file
//uniquefilename//
# 6  
Old 10-07-2014
I'm hoping this is just pseudocode.
# 7  
Old 10-07-2014
Quote:
Originally Posted by Aia
@blastif.fr
Out of curiosity, what shell do you know that uses the following syntax?
//generate a uniquefilename// as a comment or external command and then as a file
//uniquefilename//
I don't know such a shell, if you need a comment sign it's just # for both awk and bash.
A awk should just include
  • comments ( #)
  • filter - action couples ( /sample/ { ...} )
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies

2. Programming

How to call a variable in awk again ?

Hi again and thanks to R.Singh. One more question here. The code works in awk. (or GAWK) awk 'BEGIN{print "Enter your Name: ";getline name < "-";print RS "Input entered by user is: "name}' How to display the variable name again ? The awk script is running automaticly to the... (3 Replies)
Discussion started by: Zabo
3 Replies

3. Shell Programming and Scripting

awk script to call another script based on second column entry

Hi I have a text file (Input.txt) with two column entries separated by tab as given below: aaa str1 bbb str2 cccccc str3 dddd str4 eee str3 ssss str2 sdf str3 hhh str1 fff str2 ccc str3 ..... ..... ..... (1 Reply)
Discussion started by: my_Perl
1 Replies

4. Shell Programming and Scripting

Call a awk script with variable and input filename

HI, MY question is a very simple one: if i want to call an awk script with the input file name and also pass a variable value , then how to do it. #>awk -f my_script.awk -v variable=value my_inputfile.txt I can't do it like this. throws error: awk: my_script.awk:18:... (0 Replies)
Discussion started by: Onkar Banerjee
0 Replies

5. Shell Programming and Scripting

Call shell script function from awk script

hi everyone i am trying to do this bash> cat abc.sh deepak() { echo Deepak } deepak bash>./abc.sh Deepak so it is giving me write simply i created a func and it worked now i modified it like this way bash> cat abc.sh (2 Replies)
Discussion started by: aishsimplesweet
2 Replies

6. Shell Programming and Scripting

How to call parametrs to awk script

Hi All, I have script to handle nulls in column2 from file1.txt and redirect its output to file2.txt I am confused with run-time command line arguments. b'cause i normal unix we use $1 $2 for two parameters. But in awk it treat $1 as column1. So, i tried with awk -v var1 -v var2... how to... (7 Replies)
Discussion started by: kmsekhar
7 Replies

7. Shell Programming and Scripting

Passing argument to system call in awk script

So, I have this script. It reads a CSV file that has a mixture of object names with IP addresses (parsing out that part I have working), and object names which have a DNS name. I want to be able to run a "dig +short" based off of the name given to me in the line of the awk script, and then deal... (6 Replies)
Discussion started by: mikesimone
6 Replies

8. Shell Programming and Scripting

awk , function call problem

#!/bin/bash awk ' function ad(t,r){ return (t+r); } BEGIN{ print ad(5,3); } { print ad(5,3); } ' Doesn't print anything for the last print ad(5,3); (6 Replies)
Discussion started by: cola
6 Replies

9. Shell Programming and Scripting

How to call a shell script from awk ?

BEGIN { account_no = substr($0,1,8)} { billdate = substr($0,13,20)} { billduedate = substr($0,21,28)} { billid = billid - 1} { billduedate = billdatecalc(billduedate - 1)} ... END .... How do I call the shell script billdatecalc(arguments ..) in an... (1 Reply)
Discussion started by: Amruta Pitkar
1 Replies

10. UNIX for Dummies Questions & Answers

a system call for sed in a awk script

Hi, this is my test file : DELETE FROM TABLE WHERE ID_INTERNAL = :TABLE.ID-INTERNAL, ID-INTERNAL-CRAZY ID-INTERNAL-OPEN ID-INTERNAL /ID-INTERNAL/ I want all occurences of ID-INTERNAL replaced with a one, if ID-INTERNAL has and dash afer it , dont replace it example:... (6 Replies)
Discussion started by: seaten
6 Replies
Login or Register to Ask a Question