Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to open a particular file from a terminal?

Writer Sophia Terry

How do I open a file from a terminal? When I try to open a simple .txt file:

open _b2rR6eU9jJ.txt

I get this message:

Couldn't get a file descriptor referring to the console

Have I used the wrong command? Or do you use different commands to open different file types?

3

3 Answers

You can use xdg-open to open files in a terminal.

From the man-page of xdg-open:

xdg-open - opens a file or URL in the user's preferred application

Usage

The command xdg-open _b2rR6eU9jJ.txt will open the text file in a text editor that is set to handle text files. The command will also work with other common file extensions, opening the file with the relevant application.

See also:

2

You must use an editor to open a text file:

Any of those can do it:

 - vi _b2rR6eU9jJ.txt - vim _b2rR6eU9jJ.txt - emacs _b2rR6eU9jJ.txt - nano _b2rR6eU9jJ.txt - gedit _b2rR6eU9jJ.txt (gnome's default editor) - leafpad _b2rR6eU9jJ.txt (lxde's default editor) - kedit _b2rR6eU9jJ.txt (KDE's default editor)

Or if you wanted to just view the file without modifying its contents: cat _b2rR6eU9jJ.txt

EDIT #1: I just noticed that the question is tagged fedora, which up until now is using gnome as its core graphical user interface, which comes with gedit preinstalled. So this is guaranteed to work: gedit _b2rR6eU9jJ.txt

You should use an appropriate application to open it - try nano _b2rR6eU9jJ.txt or cat _b2rR6eU9jJ.txt. The former will edit, the latter will output it to standard output. (Note - you can replace nano with vi, emacs or other text editor of your preference)

From what I can tell

geek@ubuntu:~$ open --help
open: invalid option -- '-'
Usage: openvt [-c vtnumber] [-f] [-l] [-u] [-s] [-v] [-w] -- command_line

open refers to openvt - and the man page describes it as openvt - start a program on a new virtual terminal (VT). You're trying to open a text file, so unless I'm missing something, it isn't the software for doing what you want to do.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy