Wget, grep, sort, sed in 1 command/script


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Wget, grep, sort, sed in 1 command/script
# 8  
Old 04-20-2017
That's not how fifo's work.

Code:
mkfifo /tmp/jobqueue

# Need to put this in the background, since it will wait until both
# ends of the fifo are open
( wget -q -r -l1 -O /tmp/jobqueue URL/ & )

< /tmp/jobqueue grep -hrio "\b[a-z0-9.-]\+@[a-z0-9.-]\+\.[a-z]\{2,4\}\+\b" |
    sort -u |
    sed '0~5 a\\' > 7.txt

wait

rm -f /tmp/jobqueue

This User Gave Thanks to Corona688 For This Post:
# 9  
Old 04-20-2017
That's interesting, thanks. Probably getting closer?
Code:
>     sed '0~5 a\\' > 7.txt
-k or -r can be used together with -O only if outputting to a regular file.

# 10  
Old 04-20-2017
That's the clue we needed - the reason it doesn't work when you put the same command in a pipe chain.

It doesn't work simply because wget refuses to output to anything but a regular file. Pipes, named or otherwise, are no good. For -k, this is because it has to edit the file after it downloads it. For -p, this is because it opens the output file more than once. Both of which would indeed do awful things to a pipe.

So, not a lot you can do. Sorry.
This User Gave Thanks to Corona688 For This Post:
# 11  
Old 04-20-2017
Thanks for explanation; you'll see I did post that error message a few posts ago.

So I'll have to make a new directory every time I run this sequence...pretty inefficient. Anyhow if you or anyone else gets another idea on this please update. Thanks.
# 12  
Old 04-20-2017
I don't see why using a folder makes it inefficient.. What exactly are you trying to avoid?
# 13  
Old 04-20-2017
Making, and cd'ing into all those nested directories is inefficient, when I might have all the URL folders in 1 directory.
# 14  
Old 04-20-2017
If you don't want files in folders, why are you downloading recursively?

If you want multiple files, why are you downloading recursively, when you'll have no order over the order they're retrieved?

What exactly are you trying to do, that wget is not doing? What is the grep actually for? What sort of data are you retrieving?

Perhaps explain, from the beginning, what you are actually trying to do? I think we may have taken a wrong turn somewhere.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

[ask]SQL command act like sort and grep

for example, I have a text file in random content inside, maybe something like this. 234234 54654 123134 467456 24234234 7867867 23424 568567if I run this command cat "filename.txt" | sort -n | grep "^467456$" -A 1 -B 1the result is 234234 467456 568567is it possible to do this command... (2 Replies)
Discussion started by: 14th
2 Replies

2. Shell Programming and Scripting

applescript & grep - sed command

I'm new using Unix commands in applescript. The following script you choose different folders with PDfs, get file count of PDfs on chosen folders, & write the results in text file. set target_folder to choose folder with prompt "Choose target folders containing only PDFs to count files" with... (0 Replies)
Discussion started by: nellbern
0 Replies

3. Shell Programming and Scripting

Deleting lines from wget script using find/sed

I am downloading numerous files (600 plus) using a 'wget' script. Some files are not downloading and have zero byte size. I am using the following 'find' command to find the files in my cd which have non-zero byte size after the wget script has been run. find -type f -size +0 -exec basename {}... (3 Replies)
Discussion started by: dl226
3 Replies

4. Shell Programming and Scripting

Using a combination of sort/cut/grep/awk/join/paste/sed

I have a file and need to only select users that have a shell of “/bin/bash” in the line using awk or sed please help (4 Replies)
Discussion started by: boyboy1212
4 Replies

5. Shell Programming and Scripting

Shell script with wget in ssh command

Hi, I am using a linux with bash. I have a script written which will login to a remote server and from there it runs a "wget" to downlaod a build file from a webserver. Here is the line inside the script: ssh -t -q -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@${a}'wget... (4 Replies)
Discussion started by: sunrexstar
4 Replies

6. Shell Programming and Scripting

Help with grep awk sed command

I have a txt file with data abc:def:ghi:jkl:mno pq stu vwx I want to take out abc what should i do? I try awk awk '/abc/ {print $1}' listfile.txt> extendedfile.txt (5 Replies)
Discussion started by: Learnerabc
5 Replies

7. UNIX for Dummies Questions & Answers

Using grep output as input for sed command

Hi, I would like to know if this is possible, and if so what can i do to make this work. I would like to grep a line X from fileA and then use the output to replace a word Y in fileB. grep "line X" fileA | sed -e 's/Y/X/g' > outfile this statement does not work, as i do not know how to... (7 Replies)
Discussion started by: cavanac2
7 Replies

8. Shell Programming and Scripting

Complex find grep or sed command

Haven't worked in bash for ages. did a good bit of shell scripting in regular sh, but have forgotten most of it. I have several thousand php files that now include the following line at the end of the file. There is no LF or CR/LF before it begins, it is just concatenated to the final line of... (3 Replies)
Discussion started by: sjburden
3 Replies

9. UNIX for Dummies Questions & Answers

sort script/command

ok. i am doing a project where i have hand typed in the titles of nearly 500 DVD titles, each one is on a seperate line. but they arent in any type of alphebetical order, and i need them sorted in that format (A-Z or a-z) ..... i know that the 'sort' command can be used but also know the... (6 Replies)
Discussion started by: Chadbot
6 Replies
Login or Register to Ask a Question