You are not logged in.
Hi there,
I cant find a bash script that would allow me to open all links (one per line in .txt) at once.
Is there even one in the wild or has someone even the skills to publish one in this topic? It would came in handy.
In hope of supportive answers.
Last edited by ArchNewbieKernel (2021-09-07 14:46:18)
Offline
Just read each line into something like xdg-open?
What have you come up with so far?
Offline
while read url; do $BROWSER "$url"; done < url_list.txt
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
$BROWSER $(<url_list.txt)
Does not work with xdg-open.
aka Tamaranch: https://gitlab.xfce.org/Tamaranch
Offline
while read url; do $BROWSER "$url"; done < url_list.txt
#!/bin/bash
while read url; do $LibreWolf "$url"; done < YT-SUBSCRIPTIONS.txt
is outputting
./ytsubsopen.sh
./ytsubsopen.sh: line 3: $'bald and bankrupt\r': command not found
: No such file or directorytps://www.youtube.com/channel/UCxDZs_ltFFvn0FDHT6kmoXA
./ytsubsopen.sh: line 3: $'Simple History\r': command not found
: No such file or directorytps://www.youtube.com/channel/UC510QYlOlKNyhy_zdQxnGYw
./ytsubsopen.sh: line 3: $'Reactistan\r': command not found
: No such file or directorytps://www.youtube.com/channel/UCWGmhDFi3fB5DA1nuVRsPIQ
.
seems like the one-liner removes 'ht' in URL in each line.
my YT-SUBSCRIPTIONS.txt looks like this
# bald and bankrupt
https://www.youtube.com/channel/UCxDZs_ltFFvn0FDHT6kmoXA
# Simple History
https://www.youtube.com/channel/UC510QYlOlKNyhy_zdQxnGYw
# Reactistan
https://www.youtube.com/channel/UCWGmhDFi3fB5DA1nuVRsPIQ
Offline
sed '/^#/d' YT-SUBSCRIPTIONS.txt | xargs $LibreWolf
aka Tamaranch: https://gitlab.xfce.org/Tamaranch
Offline
sed '/^#/d' YT-SUBSCRIPTIONS.txt | xargs $LibreWolf
this outputs a single URL in terminal only which I can click on.
Offline
Oh this is a mac file, or windows?
To be sure:
sed -z 's/\r/\n/g' YT-SUBSCRIPTIONS.txt | sed -E '/^#|^$/d' | xargs $LibreWolf
Last edited by lambdarch (2021-09-07 09:31:10)
aka Tamaranch: https://gitlab.xfce.org/Tamaranch
Offline
Oh this is a mac file, or windows?
To be sure:sed -z 's/\r/\n/g' YT-SUBSCRIPTIONS.txt | sed -E '/^#|^$/d' | xargs $LibreWolf
??? This is a ARCH LINUX Forum.
It now displays all links in terminal instead of opening them in browser directly.
Last edited by ArchNewbieKernel (2021-09-07 09:36:40)
Offline
Well, you seem to have some "\r" in your file:
./ytsubsopen.sh: line 3: $'bald and bankrupt\r': command not found
If $LibreWolf is a web browser the above command should work, it's up to you now...
aka Tamaranch: https://gitlab.xfce.org/Tamaranch
Offline
Well, you seem to have some "\r" in your file:
ArchNewbieKernel wrote:./ytsubsopen.sh: line 3: $'bald and bankrupt\r': command not found
If $LibreWolf is a web browser the above command should work, it's up to you now...
this is wrong because there is no "\r", is just the empty void after the link in the same line.
Last edited by ArchNewbieKernel (2021-09-07 09:50:08)
Offline
Why have you replaced $BROWSER with $LibreWolf?
You were meant to either use it as-is if you have the correct environmental variable set or replace it with the name of the browser binary (excluding the $).
Offline
this is wrong because there is no "\r", is just the empty void after the link in the same line.
Don't argue with facts. You lose.
https://en.wikipedia.org/wiki/Newline
Online
ArchNewbieKernel wrote:this is wrong because there is no "\r", is just the empty void after the link in the same line.
Don't argue with facts. You lose.
https://en.wikipedia.org/wiki/Newline
I give you on that but about the solution of this topic?
Offline
Fix the EOL, then use Trilby's oneliner correctly (see Slithery's comment)
You also want to overread the comments or pick lines starting w/ http explicitly.
while read line; do [[ "$line" = "http"* ]] && librewolf "$line"; done < YT-SUBSCRIPTIONS.txt # afaics the binary is "librewolf" w/o CamelCasing
Online
Fix the EOL, then use Trilby's oneliner correctly (see Slithery's comment)
You also want to overread the comments or pick lines starting w/ http explicitly.while read line; do [[ "$line" = "http"* ]] && librewolf "$line"; done < YT-SUBSCRIPTIONS.txt # afaics the binary is "librewolf" w/o CamelCasing
Your oneliner did it, thanks.
Offline