DEV Community

Jakariya Abbas
Jakariya Abbas

Posted on

1 1 1 1 1

How to Open Windows .url Files in Arch Linux Using a Bash Script

Windows .url files store web shortcuts. If you have .url files and want to open them in Linux, follow this tutorial to create a Bash script that does it automatically.

Step 1: Create the Script File

First, open a terminal and create a new script file:

nano open-url
Enter fullscreen mode Exit fullscreen mode

This command opens the Nano text editor so you can write the script.


Step 2: Write the Bash Script

Copy and paste the following code into Nano:

#!/bin/bash

# Check if a file is provided
if [[ -z "$1" ]]; then
    echo "Usage: $0 <file.url>"
    exit 1
fi

# Check if the file exists
if [[ ! -f "$1" ]]; then
    echo "Error: File '$1' not found!"
    exit 1
fi

# Extract URL from the .url file
url=$(grep '^URL=' "$1" | cut -d'=' -f2)

# Check if URL was found
if [[ -z "$url" ]]; then
    echo "Error: No URL found in '$1'"
    exit 1
fi

# Open the URL in the default browser
xdg-open "$url"
Enter fullscreen mode Exit fullscreen mode

After pasting the script, save the file by pressing:

CTRL + XYEnter


Step 3: Make the Script Executable

Now, run this command to give the script permission to execute:

chmod +x open-url
Enter fullscreen mode Exit fullscreen mode

Step 4: Make It a System Command

To use this script from anywhere in the terminal, move it to /usr/local/bin:

sudo mv open-url /usr/local/bin/open-url
Enter fullscreen mode Exit fullscreen mode

Now, you can open any .url file like this:

open-url myshortcut.url
Enter fullscreen mode Exit fullscreen mode

Protip: You can set this as a default application/command to open .url files when clicked.

Conclusion

With this simple script, you can easily open Windows .url files in Arch Linux. It checks if the file exists, extracts the URL, and opens it in your default browser using xdg-open.

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo 📊✨

Top comments (0)

Image of DataStax

Langflow: Simplify AI Agent Building

Langflow is the easiest way to build and deploy AI-powered agents. Try it out for yourself and see why.

Get started for free

👋 Kindness is contagious

If you found this article helpful, a little ❤️ or a friendly comment would be much appreciated!

Got it