How to extract tests line by line from a text file in terminal?


User 483937

So I have a .sh script that needs to fetch a lot of files. I have a text file like this

http://www.website.com/w4w4wbvert9rtr/video.mp4
http://www.website.com/wserteg444gs4r/video.mp4
http://www.website.com/9we75y49wc45gr/video.mp4
http://www.website.com/sfwetb456/video.mp4

So I'm wondering if there is a way to extract the text line by line and insert it into wget, so I just need to run wget and then a variable.

edit:

I used G Trawo 's answer with some minor tweaks. I set it to use gnome-terminal -e "wget $line"instead of just wget $line to download all files at the same time

thanks,

Zibinsk

G Traver

The comments above already mentioned that wgetthere are --input-file=filetoggles. If you want to do this with a script, follow the steps below. Taken from here .

listofurls.txtFill a file called with all your URLs .

Create awget_readfile.sh

nano wget_readfile.sh

Paste this into it:

#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
wget $line
done < "$1"

Make it executable:

chmod +x wget_readfile.sh

run

./wget_readfile.sh listofurls.txt

Related


How to extract tests line by line from a text file in terminal?

User 483937 So I have a .sh script that needs to fetch a lot of files. I have a text file like this http://www.website.com/w4w4wbvert9rtr/video.mp4 http://www.website.com/wserteg444gs4r/video.mp4 http://www.website.com/9we75y49wc45gr/video.mp4 http://www.websi

How to extract tests line by line from a text file in terminal?

User 483937 So I have a .sh script that needs to fetch a lot of files. I have a text file like this http://www.website.com/w4w4wbvert9rtr/video.mp4 http://www.website.com/wserteg444gs4r/video.mp4 http://www.website.com/9we75y49wc45gr/video.mp4 http://www.websi

How to extract the first line from a text file?

fear I have a text file that reads like this: file=read.table("file.txt",skip="1",sep="") The first line of this text file contains information about the file, followed by observations. I want to extract the first line and write it to a new text file. skoja T

How to extract the first line from a text file?

fear I have a text file that reads like this: file=read.table("file.txt",skip="1",sep="") The first line of this text file contains information about the file, followed by observations. I want to extract the first line and write it to a new text file. skoja T

How to extract the first line from a text file?

fear I have a text file that reads like this: file=read.table("file.txt",skip="1",sep="") The first line of this text file contains information about the file, followed by observations. I want to extract the first line and write it to a new text file. skoja T

How to extract text line by line from txt file in python

Vipur I have a txt file like this: audi lamborghini ferrari pagani When I use this code: with open("test.txt") as inp: data = set(inp.read().split()) This gives the data as:['pagani', 'lamborghini', 'ferrari', 'audi'] What I want is to extract the text l

How to extract string line by line from one text file to another

Wasiu I have a text file of phone numbers like this: +2348089219281 +2348081231580 +2347088911847 +2347082645764 +2348121718153 +2348126315930 +2348023646683 I want to extract each number, remove from it +234and replace with 0, then add the following text "Nam

How to extract string line by line from one text file to another

Wasiu I have a text file of phone numbers like this: +2348089219281 +2348081231580 +2347088911847 +2347082645764 +2348121718153 +2348126315930 +2348023646683 I want to extract each number, remove from it +234and replace with 0, then add the following text "Nam

python - how to extract a string from each line of a text file?

username I have a text file that detects the number of activity monitors. I want to extract specific data from each row and include it in a list. The text file looks like this: [EnumerateDevices]: Enumerating Devices. DISPLAY\LGD03D7\4&ACE0355&1&UID68092928

How to extract numbers from a line in a Python text file

Leonard I am trying to extract a float from a line of text in a text file. I tried using that removeprefix()method but it keeps giving me an attribute error as shown below. inp = input("Enter a filename: ") var = open(inp) prefix = "X-DSPAM-Confidence: " num =

python - how to extract a string from each line of a text file?

username I have a text file that detects the number of activity monitors. I want to extract specific data from each row and include it in a list. The text file looks like this: [EnumerateDevices]: Enumerating Devices. DISPLAY\LGD03D7\4&ACE0355&1&UID68092928

Extract the second word in a line from a text file

Aaron Perry I currently need to extract the second word (CRISTOBAL) in one line of a text file. * CRISTOBAL AL042014 08/05/14 12 UTC * The second word in the "CRISTOBAL" line changes every day, so I just need to find a way to extract

Extract substring from text file on each line?

Mani Nandra Is there a way to extract substrings from each text file, for example, let's say this is a text file, but with more lines like: president, Donald Trump, 74, USA Priminster, Boris Johnson, 56, UK I will need to loop through each line and get the sub

Extract the text of each line in the file from the pattern

Wash Clark I've pored over a lot of answers, trying to hack together, but I'm running into issues that make it not work through a foreach type statement, and I can't seem to get the regex to work as a single line - if it does the foreach I want to use, then it

Extract the second word in a line from a text file

Aaron Perry I currently need to extract the second word (CRISTOBAL) in one line of a text file. * CRISTOBAL AL042014 08/05/14 12 UTC * The second word in the "CRISTOBAL" line changes every day, so I just need to find a way to extract

Extract the text of each line in the file from the pattern

Wash Clark I've pored over a lot of answers, trying to hack together, but I'm running into issues that make it not work with a foreach type statement, and I can't seem to get the regex to work as a one-liner - if it does the foreach I'm using, then it will wor

Extract substring from text file on each line?

Mani Nandra Is there a way to extract substrings from each text file, for example, let's say this is a text file, but with more lines like: president, Donald Trump, 74, USA Priminster, Boris Johnson, 56, UK I will need to loop through each line and get the sub

Extract the second word in a line from a text file

Aaron Perry I currently need to extract the second word (CRISTOBAL) in one line of a text file. * CRISTOBAL AL042014 08/05/14 12 UTC * The second word in the "CRISTOBAL" line changes every day, so I just need to find a way to extract

Extract timestamp from middle of line in text file

grab I am trying to read a text file containing different information. Part of the text file contains the following information that I need ### Size: 280 ### file data: ### Scenario: - timestamp: 1620832134319 - Wed May 12 17:08:54 CEST 2021 ### It needed to

Extract an element from a line in a text file

AbstProcDo grepThe command prints a line when the line contains a string matching the expression , which is not convenient for searching for the specified content. For example, I have glossary file with format **word** 1. Definition: 2. Usage 3. Others I want

Extract line fields from text file

Saber How can I extract the third value and all subsequent values (i.e. discard the first two) from each line of a text file containing the following values? 1 1112 0 1 2 2 1111 0 2 3 1211 1 0 3 I want to ignore 1 1112, 2 1111and 3 1211and get unique value 0

Extract line fields from text file

Saber How can I extract the third value and all subsequent values (i.e. discard the first two) from each line of a text file containing the following values? 1 1112 0 1 2 2 1111 0 2 3 1211 1 0 3 I want to ignore 1 1112, 2 1111and 3 1211and get unique value 0

Extract substring from text file on each line?

Mani Nandra Is there a way to extract substrings from each text file, for example, let's say this is a text file, but with more lines like: president, Donald Trump, 74, USA Priminster, Boris Johnson, 56, UK I will need to loop through each line and get the sub

Extract substring from text file on each line?

Mani Nandra Is there a way to extract substrings from each text file, for example, let's say this is a text file, but with more lines like: president, Donald Trump, 74, USA Priminster, Boris Johnson, 56, UK I will need to loop through each line and get the sub

Extract the text of each line in the file from the pattern

Wash Clark I've pored over a lot of answers, trying to hack together, but I'm running into issues that make it not work through a foreach type statement, and I can't seem to get the regex to work as a single line - if it does the foreach I want to use, then it

Extract the second word in a line from a text file

Aaron Perry I currently need to extract the second word (CRISTOBAL) in one line of a text file. * CRISTOBAL AL042014 08/05/14 12 UTC * The second word in the "CRISTOBAL" line changes every day, so I just need to find a way to extract

Extract substring from text file on each line?

Mani Nandra Is there a way to extract substrings from each text file, for example, let's say this is a text file, but with more lines like: president, Donald Trump, 74, USA Priminster, Boris Johnson, 56, UK I will need to loop through each line and get the sub

Extract substring from text file on each line?

Mani Nandra Is there a way to extract substrings from each text file, for example, let's say this is a text file, but with more lines like: president, Donald Trump, 74, USA Priminster, Boris Johnson, 56, UK I will need to loop through each line and get the sub

Extract substring from text file on each line?

Mani Nandra Is there a way to extract substrings from each text file, for example, let's say this is a text file, but with more lines like: president, Donald Trump, 74, USA Priminster, Boris Johnson, 56, UK I will need to loop through each line and get the sub