Score:0

Shell or bash script to open multiple URLs saved in a .TXT file in a browser from the terminal?

cn flag

Is there a shell or bash script to open multiple URLs saved in a .TXT file in a browser from the terminal?

I know that can be done with "firefox $(cat url.txt)", but:

  • I need something that saves me time by opening tabs of a maximum of 10 to 10 urls (because of RAM) from a list of 100 urls or more.

  • Which has sequential order, that they not repeat themselves and that it notify me when it reaches the end of the list.

  • That it only repeats or start again from number 1, when I close and open the terminal?

I appreciate your help!!

Jeisson Cadena avatar
cn flag
Ok, i understand @user535733 , sorry but my english is not the best, i tried my best, thanks for the advise!
Jeisson Cadena avatar
cn flag
Ok, done @user535733 ! That's the best i can!
Score:1
ca flag

Now, I hope yo're aware that askubuntu is not a script writing service.

http://www.tldp.org has at least two "Bash guides",
if you read them, even just skimmingly
you will gain knowledge that will help you solve the above problem - and many more, similar ones.

Bash commands to look into:
sort will sort your links.
head will read out a given count of lines from the beginning of a file.
tail will do the same, "beginning" from the end.

A combination of head and tail will allow you to pick out
e.g. line 15 to 25 with head -n 25 file | tail -n 10.

And one last thing; how to do loops in bash, on your list / file of links...

head -n 10 file | do read url; firefox $url ; done ...
will launch firefox on the first ten urls in the file.

Jeisson Cadena avatar
cn flag
Ok, Thank You!!! I'll try my best, hope it works!
Score:0
cn flag

This Bash script try to work, but the problem is the "access token"

I got this message on terminal:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   194  100   166  100    28    194     32 --:--:-- --:--:-- --:--:--   227
Error al obtener la información del usuario: The access token is invalid or not found in the request.
#!/bin/bash

# Nombre de usuario de TikTok a verificar
username="123abc456def"

# Realizar la solicitud a la API para obtener la información del usuario
response=$(curl -L -X POST 'https://open.tiktokapis.com/v2/research/user/info/?fields=is_private' \
-H 'Content-Type: application/json' \
-d '{"username": "'"$username"'"}')

# Verificar si la solicitud fue exitosa
if [ "$(echo "$response" | jq -r '.error.code')" == "ok" ]; then
  # Obtener el valor de "is_private" del resultado de la solicitud
  is_private=$(echo "$response" | jq -r '.data.is_private')

  # Verificar si el usuario está transmitiendo en vivo
  if [ "$is_private" == "false" ]; then
    echo "El usuario $username está transmitiendo en vivo."
  else
    echo "El usuario $username no está transmitiendo en vivo."
  fi
else
  # Error al obtener la información del usuario
  error_message=$(echo "$response" | jq -r '.error.message')
  echo "Error al obtener la información del usuario: $error_message"
fi
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.