Open a doc from terminal, but not by its name












15















Is it possible to open a file from the terminal not by its name but by its (number) position in the folder? Or any other option?



Because the name is too long.










share|improve this question









New contributor




yh yeah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 4





    Please edit and give an example of what you want to do.

    – dessert
    Mar 22 at 8:50






  • 6





    No, not without coding it. But you can use "tab" completion.

    – Rinzwind
    Mar 22 at 8:51








  • 2





    Too long for what?

    – Carl Witthoft
    Mar 22 at 11:59






  • 1





    Have you tried typing the first two or three letters of the file name and then pressin the Tab key?

    – Henrique
    Mar 22 at 20:33
















15















Is it possible to open a file from the terminal not by its name but by its (number) position in the folder? Or any other option?



Because the name is too long.










share|improve this question









New contributor




yh yeah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 4





    Please edit and give an example of what you want to do.

    – dessert
    Mar 22 at 8:50






  • 6





    No, not without coding it. But you can use "tab" completion.

    – Rinzwind
    Mar 22 at 8:51








  • 2





    Too long for what?

    – Carl Witthoft
    Mar 22 at 11:59






  • 1





    Have you tried typing the first two or three letters of the file name and then pressin the Tab key?

    – Henrique
    Mar 22 at 20:33














15












15








15


7






Is it possible to open a file from the terminal not by its name but by its (number) position in the folder? Or any other option?



Because the name is too long.










share|improve this question









New contributor




yh yeah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












Is it possible to open a file from the terminal not by its name but by its (number) position in the folder? Or any other option?



Because the name is too long.







command-line files directory






share|improve this question









New contributor




yh yeah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




yh yeah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Sergiy Kolodyazhnyy

74.5k9155325




74.5k9155325






New contributor




yh yeah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 22 at 8:47









yh yeahyh yeah

823




823




New contributor




yh yeah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





yh yeah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






yh yeah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 4





    Please edit and give an example of what you want to do.

    – dessert
    Mar 22 at 8:50






  • 6





    No, not without coding it. But you can use "tab" completion.

    – Rinzwind
    Mar 22 at 8:51








  • 2





    Too long for what?

    – Carl Witthoft
    Mar 22 at 11:59






  • 1





    Have you tried typing the first two or three letters of the file name and then pressin the Tab key?

    – Henrique
    Mar 22 at 20:33














  • 4





    Please edit and give an example of what you want to do.

    – dessert
    Mar 22 at 8:50






  • 6





    No, not without coding it. But you can use "tab" completion.

    – Rinzwind
    Mar 22 at 8:51








  • 2





    Too long for what?

    – Carl Witthoft
    Mar 22 at 11:59






  • 1





    Have you tried typing the first two or three letters of the file name and then pressin the Tab key?

    – Henrique
    Mar 22 at 20:33








4




4





Please edit and give an example of what you want to do.

– dessert
Mar 22 at 8:50





Please edit and give an example of what you want to do.

– dessert
Mar 22 at 8:50




6




6





No, not without coding it. But you can use "tab" completion.

– Rinzwind
Mar 22 at 8:51







No, not without coding it. But you can use "tab" completion.

– Rinzwind
Mar 22 at 8:51






2




2





Too long for what?

– Carl Witthoft
Mar 22 at 11:59





Too long for what?

– Carl Witthoft
Mar 22 at 11:59




1




1





Have you tried typing the first two or three letters of the file name and then pressin the Tab key?

– Henrique
Mar 22 at 20:33





Have you tried typing the first two or three letters of the file name and then pressin the Tab key?

– Henrique
Mar 22 at 20:33










9 Answers
9






active

oldest

votes


















42














You probably haven't discovered Tab-completion (see here) yet.



While typing a filename in Terminal just type a first few letters and hit Tab and see magic!






share|improve this answer



















  • 6





    Or just type the first few letters of the filename, and a *, if you don't want to use Tab-completion for some reason. Or even *abc* if the filename contains abc somewhere (try to use a subpattern that's unique to the filename you want). Or just copy/paste the filename using the mouse.

    – Guntram Blohm
    Mar 22 at 11:16






  • 4





    @guntram Or you can even drag-and-drop files to Terminal.

    – pomsky
    Mar 22 at 11:21






  • 5





    @GuntramBlohm you should make that an answer. I think it is sufficiently different from this answer to stand on its own.

    – KennyPeanuts
    Mar 22 at 15:01



















29














Just for fun, literally answering the question:



enter image description here



#!/usr/bin/env python3
import os
import subprocess

show_hidden = False

currfiles = os.listdir("./")
if not show_hidden:
currfiles = [f for f in currfiles if not f.startswith(".")]
n = 1
for f in currfiles:
print(str(n) + ". " + f)
n = n + 1

picked = int(input("Quick, quick, give me a number:n"))
subprocess.run(["xdg-open", currfiles[picked - 1]])


How it works in practice




  1. In terminal, in the working dir, run "o" (as a command)


  2. The content of the current directory is listed, numbered. Pick the number and the item is opened:



    enter image description here




Set up



...is easy:




  1. Create, if it doesn't exist yet, a folder named "bin" in your home directory

  2. Copy the script into an empty file, save it as (literally) "o" (no extension), and make it executable


  3. Log out and back in and start using the command by just typing



    $ o


    in terminal




N.B.



If you'd like to show hidden files as well, change



show_hidden = False


into:



show_hidden = True





share|improve this answer





















  • 1





    If ~/bin isn't already in your PATH, you'll have to add it (for instance, putting a line like export PATH="$PATH:~/bin" into .bashrc or .profile.)

    – kundor
    Mar 22 at 20:08













  • See b0fh's answer - this seems to be a built-in from bash

    – mgarciaisaia
    Mar 22 at 20:25











  • @kundor nope, not on Ubuntu. Log out and in does the job, or simply source ~/.profile.

    – Jacob Vlijm
    Mar 22 at 20:47











  • @JacobVlijm ~/bin is not built into anything at all. Ubuntu and Debian ship with custom ~/.profile that has lines if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" ; fi. On Mac OS X and CentOS you have to configure that yourself. A good chance is that if Ubuntu is provided to a person by IT department, chances are the ~/.profile won't be the same as default Ubuntu, so it's a good practice to always beware that ~/bin is not standard. Bash also can ignore ~/.profile if you launch the shell with --no-profile option

    – Sergiy Kolodyazhnyy
    2 days ago











  • @mgarciaisaia Original comment was meant for you, actually ^

    – Sergiy Kolodyazhnyy
    2 days ago



















26














There is a little-known feature in Bash that allows you to do this without calling on python or any other third-party tool, and with a single line:



select file in *; do open "$file"; break; done





share|improve this answer








New contributor




b0fh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 7





    Excellent! open typically won't work, though (unless you're on Mac OS); xdg-open will probably do the trick on most GNU/Linux systems.

    – kundor
    Mar 22 at 20:11






  • 1





    But bash is not the only shell in existence, you know :-)

    – jamesqf
    2 days ago



















14














In pure bash, using the select statement:



PS3='Quick, quick, give a number: '

select file in *
do
xdg-open "$file"
break
done


Setting PS3 is just eyecandy. If you leave it out, you will just get the default prompt. If you leave out the break statement, the select statement will loop until you hit CTRL-D or CTRL-C.



Of course you can also run it as a one-liner:



select file in *; do xdg-open "$file"; break; done





share|improve this answer








New contributor




Oscar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Simple enough of a solution and works well enough. You can go a step further and make an alias or function out of it

    – Sergiy Kolodyazhnyy
    2 days ago



















7














You can install and use mc, Midnight Commander. It is a text user interface with menus etc inspired by the old Norton Commander, that was popular when people used MSDOS (before Windows).



sudo apt update
sudo apt install mc


and start it in a terminal window or in a text screen,



mc





share|improve this answer































    4














    $ ls



    results.log
    string
    Templates
    textfile
    time
    time.save
    vegetables
    vegetablesbsh


    How bout



    ls | sed -n 3p



    Prints 3rd file name



    Templates



    Open it-



    xdg-open "$(ls | sed -n 3p)"



    Usually works.



    Put it in a script



    #!/bin/bash

    xdg-open "$(ls | sed -n "$1"p)"



    Name of script: open



    Save it in home folder.
    Run:



    ./open file_number





    share|improve this answer





















    • 8





      Why you shouldn't parse the output of ls

      – dessert
      Mar 22 at 12:20






    • 1





      Why not parse ls (and what do to instead)?

      – phuclv
      2 days ago



















    1














    On Linux filesystems, filenames have a very interesting property called inode: a directory ( or folder ) is a listing of inodes and which filenames point to those inodes. So, if you know the inode number, you can attempt to locate the file using find utility and do certain operations on it. This is especially useful when dealing with filenames in different locale, special characters, or when you accidentally created directory called ~.



    For example,



    $ ls -i1
    1103993 crs.py
    1103743 foobar.txt
    1147196 __pycache__
    1103739 'with'$'n''newline.png'
    1103740 yellowstone.jpg

    $ find . -type f -inum 1103743 -exec xdg-open {} ; -and -quit


    What this does is traverse current working directory ( represented by . ) and look for directory entry that is a file with inode number 1103743. If the file is found, xdg-open will open the file with default application and find will quit afterwards. The reason for the extra -and and -quit is to prevent xdg-open reopening the file if there exist hard links to the file (which is equivalent to opening the same file twice).






    share|improve this answer































      1














      Make some files:



      $ for i in $(seq -w 0 20); do echo "This is file $i." > $i.txt; done
      $ ls
      00.txt 03.txt 06.txt 09.txt 12.txt 15.txt 18.txt
      01.txt 04.txt 07.txt 10.txt 13.txt 16.txt 19.txt
      02.txt 05.txt 08.txt 11.txt 14.txt 17.txt 20.txt
      $ cat 16.txt
      This is file 16.


      Put the files into a variable and open the file by an index.



      $ files=(*)
      $ xdg-open "${files[12]}"
      # Opens 12.txt in a text editor, which reads "This is file 12."


      Replace 12 with the index you're trying to open.






      share|improve this answer


























      • I'd prefer {00..20} instead of $(seq -w 0 20) because it's just one external process less to spawn. I'm not sure about portability though. Might be a bash-ism.. ;-)

        – Oscar
        10 hours ago



















      0














      This is probably the simplest answer that directly answers the question.
      try the following:



      touch file-1 file-2 file-3


      Let's say we want to open (or edit) the second file, we can do the following:



      echo `ls` | cut -d' ' -f2


      this will output the name of the second file, which we can use as input to the command we want to perform, for example:



      cat $( echo `ls` | cut -d' ' -f2 )


      will output the content of the second file.




      note that you can change the order in which the files are printed by ls, by tweaking ls arguments, see man ls for details.




      [UPDATE] this assumes that you have no white-spaces in file names,

      thanks @wjandrea for your observation.






      share|improve this answer










      New contributor




      HElanabi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
















      • 1





        This will fail for filenames that contain spaces. This answer gets around that, but it's still a bad idea to parse ls. Also backticks are deprecated. Use $() instead.

        – wjandrea
        2 days ago











      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "89"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });






      yh yeah is a new contributor. Be nice, and check out our Code of Conduct.










      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1127755%2fopen-a-doc-from-terminal-but-not-by-its-name%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      9 Answers
      9






      active

      oldest

      votes








      9 Answers
      9






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      42














      You probably haven't discovered Tab-completion (see here) yet.



      While typing a filename in Terminal just type a first few letters and hit Tab and see magic!






      share|improve this answer



















      • 6





        Or just type the first few letters of the filename, and a *, if you don't want to use Tab-completion for some reason. Or even *abc* if the filename contains abc somewhere (try to use a subpattern that's unique to the filename you want). Or just copy/paste the filename using the mouse.

        – Guntram Blohm
        Mar 22 at 11:16






      • 4





        @guntram Or you can even drag-and-drop files to Terminal.

        – pomsky
        Mar 22 at 11:21






      • 5





        @GuntramBlohm you should make that an answer. I think it is sufficiently different from this answer to stand on its own.

        – KennyPeanuts
        Mar 22 at 15:01
















      42














      You probably haven't discovered Tab-completion (see here) yet.



      While typing a filename in Terminal just type a first few letters and hit Tab and see magic!






      share|improve this answer



















      • 6





        Or just type the first few letters of the filename, and a *, if you don't want to use Tab-completion for some reason. Or even *abc* if the filename contains abc somewhere (try to use a subpattern that's unique to the filename you want). Or just copy/paste the filename using the mouse.

        – Guntram Blohm
        Mar 22 at 11:16






      • 4





        @guntram Or you can even drag-and-drop files to Terminal.

        – pomsky
        Mar 22 at 11:21






      • 5





        @GuntramBlohm you should make that an answer. I think it is sufficiently different from this answer to stand on its own.

        – KennyPeanuts
        Mar 22 at 15:01














      42












      42








      42







      You probably haven't discovered Tab-completion (see here) yet.



      While typing a filename in Terminal just type a first few letters and hit Tab and see magic!






      share|improve this answer













      You probably haven't discovered Tab-completion (see here) yet.



      While typing a filename in Terminal just type a first few letters and hit Tab and see magic!







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Mar 22 at 8:51









      pomskypomsky

      32.8k11103135




      32.8k11103135








      • 6





        Or just type the first few letters of the filename, and a *, if you don't want to use Tab-completion for some reason. Or even *abc* if the filename contains abc somewhere (try to use a subpattern that's unique to the filename you want). Or just copy/paste the filename using the mouse.

        – Guntram Blohm
        Mar 22 at 11:16






      • 4





        @guntram Or you can even drag-and-drop files to Terminal.

        – pomsky
        Mar 22 at 11:21






      • 5





        @GuntramBlohm you should make that an answer. I think it is sufficiently different from this answer to stand on its own.

        – KennyPeanuts
        Mar 22 at 15:01














      • 6





        Or just type the first few letters of the filename, and a *, if you don't want to use Tab-completion for some reason. Or even *abc* if the filename contains abc somewhere (try to use a subpattern that's unique to the filename you want). Or just copy/paste the filename using the mouse.

        – Guntram Blohm
        Mar 22 at 11:16






      • 4





        @guntram Or you can even drag-and-drop files to Terminal.

        – pomsky
        Mar 22 at 11:21






      • 5





        @GuntramBlohm you should make that an answer. I think it is sufficiently different from this answer to stand on its own.

        – KennyPeanuts
        Mar 22 at 15:01








      6




      6





      Or just type the first few letters of the filename, and a *, if you don't want to use Tab-completion for some reason. Or even *abc* if the filename contains abc somewhere (try to use a subpattern that's unique to the filename you want). Or just copy/paste the filename using the mouse.

      – Guntram Blohm
      Mar 22 at 11:16





      Or just type the first few letters of the filename, and a *, if you don't want to use Tab-completion for some reason. Or even *abc* if the filename contains abc somewhere (try to use a subpattern that's unique to the filename you want). Or just copy/paste the filename using the mouse.

      – Guntram Blohm
      Mar 22 at 11:16




      4




      4





      @guntram Or you can even drag-and-drop files to Terminal.

      – pomsky
      Mar 22 at 11:21





      @guntram Or you can even drag-and-drop files to Terminal.

      – pomsky
      Mar 22 at 11:21




      5




      5





      @GuntramBlohm you should make that an answer. I think it is sufficiently different from this answer to stand on its own.

      – KennyPeanuts
      Mar 22 at 15:01





      @GuntramBlohm you should make that an answer. I think it is sufficiently different from this answer to stand on its own.

      – KennyPeanuts
      Mar 22 at 15:01













      29














      Just for fun, literally answering the question:



      enter image description here



      #!/usr/bin/env python3
      import os
      import subprocess

      show_hidden = False

      currfiles = os.listdir("./")
      if not show_hidden:
      currfiles = [f for f in currfiles if not f.startswith(".")]
      n = 1
      for f in currfiles:
      print(str(n) + ". " + f)
      n = n + 1

      picked = int(input("Quick, quick, give me a number:n"))
      subprocess.run(["xdg-open", currfiles[picked - 1]])


      How it works in practice




      1. In terminal, in the working dir, run "o" (as a command)


      2. The content of the current directory is listed, numbered. Pick the number and the item is opened:



        enter image description here




      Set up



      ...is easy:




      1. Create, if it doesn't exist yet, a folder named "bin" in your home directory

      2. Copy the script into an empty file, save it as (literally) "o" (no extension), and make it executable


      3. Log out and back in and start using the command by just typing



        $ o


        in terminal




      N.B.



      If you'd like to show hidden files as well, change



      show_hidden = False


      into:



      show_hidden = True





      share|improve this answer





















      • 1





        If ~/bin isn't already in your PATH, you'll have to add it (for instance, putting a line like export PATH="$PATH:~/bin" into .bashrc or .profile.)

        – kundor
        Mar 22 at 20:08













      • See b0fh's answer - this seems to be a built-in from bash

        – mgarciaisaia
        Mar 22 at 20:25











      • @kundor nope, not on Ubuntu. Log out and in does the job, or simply source ~/.profile.

        – Jacob Vlijm
        Mar 22 at 20:47











      • @JacobVlijm ~/bin is not built into anything at all. Ubuntu and Debian ship with custom ~/.profile that has lines if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" ; fi. On Mac OS X and CentOS you have to configure that yourself. A good chance is that if Ubuntu is provided to a person by IT department, chances are the ~/.profile won't be the same as default Ubuntu, so it's a good practice to always beware that ~/bin is not standard. Bash also can ignore ~/.profile if you launch the shell with --no-profile option

        – Sergiy Kolodyazhnyy
        2 days ago











      • @mgarciaisaia Original comment was meant for you, actually ^

        – Sergiy Kolodyazhnyy
        2 days ago
















      29














      Just for fun, literally answering the question:



      enter image description here



      #!/usr/bin/env python3
      import os
      import subprocess

      show_hidden = False

      currfiles = os.listdir("./")
      if not show_hidden:
      currfiles = [f for f in currfiles if not f.startswith(".")]
      n = 1
      for f in currfiles:
      print(str(n) + ". " + f)
      n = n + 1

      picked = int(input("Quick, quick, give me a number:n"))
      subprocess.run(["xdg-open", currfiles[picked - 1]])


      How it works in practice




      1. In terminal, in the working dir, run "o" (as a command)


      2. The content of the current directory is listed, numbered. Pick the number and the item is opened:



        enter image description here




      Set up



      ...is easy:




      1. Create, if it doesn't exist yet, a folder named "bin" in your home directory

      2. Copy the script into an empty file, save it as (literally) "o" (no extension), and make it executable


      3. Log out and back in and start using the command by just typing



        $ o


        in terminal




      N.B.



      If you'd like to show hidden files as well, change



      show_hidden = False


      into:



      show_hidden = True





      share|improve this answer





















      • 1





        If ~/bin isn't already in your PATH, you'll have to add it (for instance, putting a line like export PATH="$PATH:~/bin" into .bashrc or .profile.)

        – kundor
        Mar 22 at 20:08













      • See b0fh's answer - this seems to be a built-in from bash

        – mgarciaisaia
        Mar 22 at 20:25











      • @kundor nope, not on Ubuntu. Log out and in does the job, or simply source ~/.profile.

        – Jacob Vlijm
        Mar 22 at 20:47











      • @JacobVlijm ~/bin is not built into anything at all. Ubuntu and Debian ship with custom ~/.profile that has lines if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" ; fi. On Mac OS X and CentOS you have to configure that yourself. A good chance is that if Ubuntu is provided to a person by IT department, chances are the ~/.profile won't be the same as default Ubuntu, so it's a good practice to always beware that ~/bin is not standard. Bash also can ignore ~/.profile if you launch the shell with --no-profile option

        – Sergiy Kolodyazhnyy
        2 days ago











      • @mgarciaisaia Original comment was meant for you, actually ^

        – Sergiy Kolodyazhnyy
        2 days ago














      29












      29








      29







      Just for fun, literally answering the question:



      enter image description here



      #!/usr/bin/env python3
      import os
      import subprocess

      show_hidden = False

      currfiles = os.listdir("./")
      if not show_hidden:
      currfiles = [f for f in currfiles if not f.startswith(".")]
      n = 1
      for f in currfiles:
      print(str(n) + ". " + f)
      n = n + 1

      picked = int(input("Quick, quick, give me a number:n"))
      subprocess.run(["xdg-open", currfiles[picked - 1]])


      How it works in practice




      1. In terminal, in the working dir, run "o" (as a command)


      2. The content of the current directory is listed, numbered. Pick the number and the item is opened:



        enter image description here




      Set up



      ...is easy:




      1. Create, if it doesn't exist yet, a folder named "bin" in your home directory

      2. Copy the script into an empty file, save it as (literally) "o" (no extension), and make it executable


      3. Log out and back in and start using the command by just typing



        $ o


        in terminal




      N.B.



      If you'd like to show hidden files as well, change



      show_hidden = False


      into:



      show_hidden = True





      share|improve this answer















      Just for fun, literally answering the question:



      enter image description here



      #!/usr/bin/env python3
      import os
      import subprocess

      show_hidden = False

      currfiles = os.listdir("./")
      if not show_hidden:
      currfiles = [f for f in currfiles if not f.startswith(".")]
      n = 1
      for f in currfiles:
      print(str(n) + ". " + f)
      n = n + 1

      picked = int(input("Quick, quick, give me a number:n"))
      subprocess.run(["xdg-open", currfiles[picked - 1]])


      How it works in practice




      1. In terminal, in the working dir, run "o" (as a command)


      2. The content of the current directory is listed, numbered. Pick the number and the item is opened:



        enter image description here




      Set up



      ...is easy:




      1. Create, if it doesn't exist yet, a folder named "bin" in your home directory

      2. Copy the script into an empty file, save it as (literally) "o" (no extension), and make it executable


      3. Log out and back in and start using the command by just typing



        $ o


        in terminal




      N.B.



      If you'd like to show hidden files as well, change



      show_hidden = False


      into:



      show_hidden = True






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 22 at 10:23

























      answered Mar 22 at 9:25









      Jacob VlijmJacob Vlijm

      65.5k9130226




      65.5k9130226








      • 1





        If ~/bin isn't already in your PATH, you'll have to add it (for instance, putting a line like export PATH="$PATH:~/bin" into .bashrc or .profile.)

        – kundor
        Mar 22 at 20:08













      • See b0fh's answer - this seems to be a built-in from bash

        – mgarciaisaia
        Mar 22 at 20:25











      • @kundor nope, not on Ubuntu. Log out and in does the job, or simply source ~/.profile.

        – Jacob Vlijm
        Mar 22 at 20:47











      • @JacobVlijm ~/bin is not built into anything at all. Ubuntu and Debian ship with custom ~/.profile that has lines if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" ; fi. On Mac OS X and CentOS you have to configure that yourself. A good chance is that if Ubuntu is provided to a person by IT department, chances are the ~/.profile won't be the same as default Ubuntu, so it's a good practice to always beware that ~/bin is not standard. Bash also can ignore ~/.profile if you launch the shell with --no-profile option

        – Sergiy Kolodyazhnyy
        2 days ago











      • @mgarciaisaia Original comment was meant for you, actually ^

        – Sergiy Kolodyazhnyy
        2 days ago














      • 1





        If ~/bin isn't already in your PATH, you'll have to add it (for instance, putting a line like export PATH="$PATH:~/bin" into .bashrc or .profile.)

        – kundor
        Mar 22 at 20:08













      • See b0fh's answer - this seems to be a built-in from bash

        – mgarciaisaia
        Mar 22 at 20:25











      • @kundor nope, not on Ubuntu. Log out and in does the job, or simply source ~/.profile.

        – Jacob Vlijm
        Mar 22 at 20:47











      • @JacobVlijm ~/bin is not built into anything at all. Ubuntu and Debian ship with custom ~/.profile that has lines if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" ; fi. On Mac OS X and CentOS you have to configure that yourself. A good chance is that if Ubuntu is provided to a person by IT department, chances are the ~/.profile won't be the same as default Ubuntu, so it's a good practice to always beware that ~/bin is not standard. Bash also can ignore ~/.profile if you launch the shell with --no-profile option

        – Sergiy Kolodyazhnyy
        2 days ago











      • @mgarciaisaia Original comment was meant for you, actually ^

        – Sergiy Kolodyazhnyy
        2 days ago








      1




      1





      If ~/bin isn't already in your PATH, you'll have to add it (for instance, putting a line like export PATH="$PATH:~/bin" into .bashrc or .profile.)

      – kundor
      Mar 22 at 20:08







      If ~/bin isn't already in your PATH, you'll have to add it (for instance, putting a line like export PATH="$PATH:~/bin" into .bashrc or .profile.)

      – kundor
      Mar 22 at 20:08















      See b0fh's answer - this seems to be a built-in from bash

      – mgarciaisaia
      Mar 22 at 20:25





      See b0fh's answer - this seems to be a built-in from bash

      – mgarciaisaia
      Mar 22 at 20:25













      @kundor nope, not on Ubuntu. Log out and in does the job, or simply source ~/.profile.

      – Jacob Vlijm
      Mar 22 at 20:47





      @kundor nope, not on Ubuntu. Log out and in does the job, or simply source ~/.profile.

      – Jacob Vlijm
      Mar 22 at 20:47













      @JacobVlijm ~/bin is not built into anything at all. Ubuntu and Debian ship with custom ~/.profile that has lines if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" ; fi. On Mac OS X and CentOS you have to configure that yourself. A good chance is that if Ubuntu is provided to a person by IT department, chances are the ~/.profile won't be the same as default Ubuntu, so it's a good practice to always beware that ~/bin is not standard. Bash also can ignore ~/.profile if you launch the shell with --no-profile option

      – Sergiy Kolodyazhnyy
      2 days ago





      @JacobVlijm ~/bin is not built into anything at all. Ubuntu and Debian ship with custom ~/.profile that has lines if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" ; fi. On Mac OS X and CentOS you have to configure that yourself. A good chance is that if Ubuntu is provided to a person by IT department, chances are the ~/.profile won't be the same as default Ubuntu, so it's a good practice to always beware that ~/bin is not standard. Bash also can ignore ~/.profile if you launch the shell with --no-profile option

      – Sergiy Kolodyazhnyy
      2 days ago













      @mgarciaisaia Original comment was meant for you, actually ^

      – Sergiy Kolodyazhnyy
      2 days ago





      @mgarciaisaia Original comment was meant for you, actually ^

      – Sergiy Kolodyazhnyy
      2 days ago











      26














      There is a little-known feature in Bash that allows you to do this without calling on python or any other third-party tool, and with a single line:



      select file in *; do open "$file"; break; done





      share|improve this answer








      New contributor




      b0fh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
















      • 7





        Excellent! open typically won't work, though (unless you're on Mac OS); xdg-open will probably do the trick on most GNU/Linux systems.

        – kundor
        Mar 22 at 20:11






      • 1





        But bash is not the only shell in existence, you know :-)

        – jamesqf
        2 days ago
















      26














      There is a little-known feature in Bash that allows you to do this without calling on python or any other third-party tool, and with a single line:



      select file in *; do open "$file"; break; done





      share|improve this answer








      New contributor




      b0fh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
















      • 7





        Excellent! open typically won't work, though (unless you're on Mac OS); xdg-open will probably do the trick on most GNU/Linux systems.

        – kundor
        Mar 22 at 20:11






      • 1





        But bash is not the only shell in existence, you know :-)

        – jamesqf
        2 days ago














      26












      26








      26







      There is a little-known feature in Bash that allows you to do this without calling on python or any other third-party tool, and with a single line:



      select file in *; do open "$file"; break; done





      share|improve this answer








      New contributor




      b0fh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      There is a little-known feature in Bash that allows you to do this without calling on python or any other third-party tool, and with a single line:



      select file in *; do open "$file"; break; done






      share|improve this answer








      New contributor




      b0fh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this answer



      share|improve this answer






      New contributor




      b0fh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      answered Mar 22 at 13:10









      b0fhb0fh

      36123




      36123




      New contributor




      b0fh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      b0fh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      b0fh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      • 7





        Excellent! open typically won't work, though (unless you're on Mac OS); xdg-open will probably do the trick on most GNU/Linux systems.

        – kundor
        Mar 22 at 20:11






      • 1





        But bash is not the only shell in existence, you know :-)

        – jamesqf
        2 days ago














      • 7





        Excellent! open typically won't work, though (unless you're on Mac OS); xdg-open will probably do the trick on most GNU/Linux systems.

        – kundor
        Mar 22 at 20:11






      • 1





        But bash is not the only shell in existence, you know :-)

        – jamesqf
        2 days ago








      7




      7





      Excellent! open typically won't work, though (unless you're on Mac OS); xdg-open will probably do the trick on most GNU/Linux systems.

      – kundor
      Mar 22 at 20:11





      Excellent! open typically won't work, though (unless you're on Mac OS); xdg-open will probably do the trick on most GNU/Linux systems.

      – kundor
      Mar 22 at 20:11




      1




      1





      But bash is not the only shell in existence, you know :-)

      – jamesqf
      2 days ago





      But bash is not the only shell in existence, you know :-)

      – jamesqf
      2 days ago











      14














      In pure bash, using the select statement:



      PS3='Quick, quick, give a number: '

      select file in *
      do
      xdg-open "$file"
      break
      done


      Setting PS3 is just eyecandy. If you leave it out, you will just get the default prompt. If you leave out the break statement, the select statement will loop until you hit CTRL-D or CTRL-C.



      Of course you can also run it as a one-liner:



      select file in *; do xdg-open "$file"; break; done





      share|improve this answer








      New contributor




      Oscar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





















      • Simple enough of a solution and works well enough. You can go a step further and make an alias or function out of it

        – Sergiy Kolodyazhnyy
        2 days ago
















      14














      In pure bash, using the select statement:



      PS3='Quick, quick, give a number: '

      select file in *
      do
      xdg-open "$file"
      break
      done


      Setting PS3 is just eyecandy. If you leave it out, you will just get the default prompt. If you leave out the break statement, the select statement will loop until you hit CTRL-D or CTRL-C.



      Of course you can also run it as a one-liner:



      select file in *; do xdg-open "$file"; break; done





      share|improve this answer








      New contributor




      Oscar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





















      • Simple enough of a solution and works well enough. You can go a step further and make an alias or function out of it

        – Sergiy Kolodyazhnyy
        2 days ago














      14












      14








      14







      In pure bash, using the select statement:



      PS3='Quick, quick, give a number: '

      select file in *
      do
      xdg-open "$file"
      break
      done


      Setting PS3 is just eyecandy. If you leave it out, you will just get the default prompt. If you leave out the break statement, the select statement will loop until you hit CTRL-D or CTRL-C.



      Of course you can also run it as a one-liner:



      select file in *; do xdg-open "$file"; break; done





      share|improve this answer








      New contributor




      Oscar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      In pure bash, using the select statement:



      PS3='Quick, quick, give a number: '

      select file in *
      do
      xdg-open "$file"
      break
      done


      Setting PS3 is just eyecandy. If you leave it out, you will just get the default prompt. If you leave out the break statement, the select statement will loop until you hit CTRL-D or CTRL-C.



      Of course you can also run it as a one-liner:



      select file in *; do xdg-open "$file"; break; done






      share|improve this answer








      New contributor




      Oscar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this answer



      share|improve this answer






      New contributor




      Oscar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      answered Mar 22 at 13:12









      OscarOscar

      1435




      1435




      New contributor




      Oscar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Oscar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Oscar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.













      • Simple enough of a solution and works well enough. You can go a step further and make an alias or function out of it

        – Sergiy Kolodyazhnyy
        2 days ago



















      • Simple enough of a solution and works well enough. You can go a step further and make an alias or function out of it

        – Sergiy Kolodyazhnyy
        2 days ago

















      Simple enough of a solution and works well enough. You can go a step further and make an alias or function out of it

      – Sergiy Kolodyazhnyy
      2 days ago





      Simple enough of a solution and works well enough. You can go a step further and make an alias or function out of it

      – Sergiy Kolodyazhnyy
      2 days ago











      7














      You can install and use mc, Midnight Commander. It is a text user interface with menus etc inspired by the old Norton Commander, that was popular when people used MSDOS (before Windows).



      sudo apt update
      sudo apt install mc


      and start it in a terminal window or in a text screen,



      mc





      share|improve this answer




























        7














        You can install and use mc, Midnight Commander. It is a text user interface with menus etc inspired by the old Norton Commander, that was popular when people used MSDOS (before Windows).



        sudo apt update
        sudo apt install mc


        and start it in a terminal window or in a text screen,



        mc





        share|improve this answer


























          7












          7








          7







          You can install and use mc, Midnight Commander. It is a text user interface with menus etc inspired by the old Norton Commander, that was popular when people used MSDOS (before Windows).



          sudo apt update
          sudo apt install mc


          and start it in a terminal window or in a text screen,



          mc





          share|improve this answer













          You can install and use mc, Midnight Commander. It is a text user interface with menus etc inspired by the old Norton Commander, that was popular when people used MSDOS (before Windows).



          sudo apt update
          sudo apt install mc


          and start it in a terminal window or in a text screen,



          mc






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 at 9:42









          sudodussudodus

          25.5k33078




          25.5k33078























              4














              $ ls



              results.log
              string
              Templates
              textfile
              time
              time.save
              vegetables
              vegetablesbsh


              How bout



              ls | sed -n 3p



              Prints 3rd file name



              Templates



              Open it-



              xdg-open "$(ls | sed -n 3p)"



              Usually works.



              Put it in a script



              #!/bin/bash

              xdg-open "$(ls | sed -n "$1"p)"



              Name of script: open



              Save it in home folder.
              Run:



              ./open file_number





              share|improve this answer





















              • 8





                Why you shouldn't parse the output of ls

                – dessert
                Mar 22 at 12:20






              • 1





                Why not parse ls (and what do to instead)?

                – phuclv
                2 days ago
















              4














              $ ls



              results.log
              string
              Templates
              textfile
              time
              time.save
              vegetables
              vegetablesbsh


              How bout



              ls | sed -n 3p



              Prints 3rd file name



              Templates



              Open it-



              xdg-open "$(ls | sed -n 3p)"



              Usually works.



              Put it in a script



              #!/bin/bash

              xdg-open "$(ls | sed -n "$1"p)"



              Name of script: open



              Save it in home folder.
              Run:



              ./open file_number





              share|improve this answer





















              • 8





                Why you shouldn't parse the output of ls

                – dessert
                Mar 22 at 12:20






              • 1





                Why not parse ls (and what do to instead)?

                – phuclv
                2 days ago














              4












              4








              4







              $ ls



              results.log
              string
              Templates
              textfile
              time
              time.save
              vegetables
              vegetablesbsh


              How bout



              ls | sed -n 3p



              Prints 3rd file name



              Templates



              Open it-



              xdg-open "$(ls | sed -n 3p)"



              Usually works.



              Put it in a script



              #!/bin/bash

              xdg-open "$(ls | sed -n "$1"p)"



              Name of script: open



              Save it in home folder.
              Run:



              ./open file_number





              share|improve this answer















              $ ls



              results.log
              string
              Templates
              textfile
              time
              time.save
              vegetables
              vegetablesbsh


              How bout



              ls | sed -n 3p



              Prints 3rd file name



              Templates



              Open it-



              xdg-open "$(ls | sed -n 3p)"



              Usually works.



              Put it in a script



              #!/bin/bash

              xdg-open "$(ls | sed -n "$1"p)"



              Name of script: open



              Save it in home folder.
              Run:



              ./open file_number






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Mar 22 at 9:54


























              community wiki





              2 revs
              measSelf









              • 8





                Why you shouldn't parse the output of ls

                – dessert
                Mar 22 at 12:20






              • 1





                Why not parse ls (and what do to instead)?

                – phuclv
                2 days ago














              • 8





                Why you shouldn't parse the output of ls

                – dessert
                Mar 22 at 12:20






              • 1





                Why not parse ls (and what do to instead)?

                – phuclv
                2 days ago








              8




              8





              Why you shouldn't parse the output of ls

              – dessert
              Mar 22 at 12:20





              Why you shouldn't parse the output of ls

              – dessert
              Mar 22 at 12:20




              1




              1





              Why not parse ls (and what do to instead)?

              – phuclv
              2 days ago





              Why not parse ls (and what do to instead)?

              – phuclv
              2 days ago











              1














              On Linux filesystems, filenames have a very interesting property called inode: a directory ( or folder ) is a listing of inodes and which filenames point to those inodes. So, if you know the inode number, you can attempt to locate the file using find utility and do certain operations on it. This is especially useful when dealing with filenames in different locale, special characters, or when you accidentally created directory called ~.



              For example,



              $ ls -i1
              1103993 crs.py
              1103743 foobar.txt
              1147196 __pycache__
              1103739 'with'$'n''newline.png'
              1103740 yellowstone.jpg

              $ find . -type f -inum 1103743 -exec xdg-open {} ; -and -quit


              What this does is traverse current working directory ( represented by . ) and look for directory entry that is a file with inode number 1103743. If the file is found, xdg-open will open the file with default application and find will quit afterwards. The reason for the extra -and and -quit is to prevent xdg-open reopening the file if there exist hard links to the file (which is equivalent to opening the same file twice).






              share|improve this answer




























                1














                On Linux filesystems, filenames have a very interesting property called inode: a directory ( or folder ) is a listing of inodes and which filenames point to those inodes. So, if you know the inode number, you can attempt to locate the file using find utility and do certain operations on it. This is especially useful when dealing with filenames in different locale, special characters, or when you accidentally created directory called ~.



                For example,



                $ ls -i1
                1103993 crs.py
                1103743 foobar.txt
                1147196 __pycache__
                1103739 'with'$'n''newline.png'
                1103740 yellowstone.jpg

                $ find . -type f -inum 1103743 -exec xdg-open {} ; -and -quit


                What this does is traverse current working directory ( represented by . ) and look for directory entry that is a file with inode number 1103743. If the file is found, xdg-open will open the file with default application and find will quit afterwards. The reason for the extra -and and -quit is to prevent xdg-open reopening the file if there exist hard links to the file (which is equivalent to opening the same file twice).






                share|improve this answer


























                  1












                  1








                  1







                  On Linux filesystems, filenames have a very interesting property called inode: a directory ( or folder ) is a listing of inodes and which filenames point to those inodes. So, if you know the inode number, you can attempt to locate the file using find utility and do certain operations on it. This is especially useful when dealing with filenames in different locale, special characters, or when you accidentally created directory called ~.



                  For example,



                  $ ls -i1
                  1103993 crs.py
                  1103743 foobar.txt
                  1147196 __pycache__
                  1103739 'with'$'n''newline.png'
                  1103740 yellowstone.jpg

                  $ find . -type f -inum 1103743 -exec xdg-open {} ; -and -quit


                  What this does is traverse current working directory ( represented by . ) and look for directory entry that is a file with inode number 1103743. If the file is found, xdg-open will open the file with default application and find will quit afterwards. The reason for the extra -and and -quit is to prevent xdg-open reopening the file if there exist hard links to the file (which is equivalent to opening the same file twice).






                  share|improve this answer













                  On Linux filesystems, filenames have a very interesting property called inode: a directory ( or folder ) is a listing of inodes and which filenames point to those inodes. So, if you know the inode number, you can attempt to locate the file using find utility and do certain operations on it. This is especially useful when dealing with filenames in different locale, special characters, or when you accidentally created directory called ~.



                  For example,



                  $ ls -i1
                  1103993 crs.py
                  1103743 foobar.txt
                  1147196 __pycache__
                  1103739 'with'$'n''newline.png'
                  1103740 yellowstone.jpg

                  $ find . -type f -inum 1103743 -exec xdg-open {} ; -and -quit


                  What this does is traverse current working directory ( represented by . ) and look for directory entry that is a file with inode number 1103743. If the file is found, xdg-open will open the file with default application and find will quit afterwards. The reason for the extra -and and -quit is to prevent xdg-open reopening the file if there exist hard links to the file (which is equivalent to opening the same file twice).







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 days ago









                  Sergiy KolodyazhnyySergiy Kolodyazhnyy

                  74.5k9155325




                  74.5k9155325























                      1














                      Make some files:



                      $ for i in $(seq -w 0 20); do echo "This is file $i." > $i.txt; done
                      $ ls
                      00.txt 03.txt 06.txt 09.txt 12.txt 15.txt 18.txt
                      01.txt 04.txt 07.txt 10.txt 13.txt 16.txt 19.txt
                      02.txt 05.txt 08.txt 11.txt 14.txt 17.txt 20.txt
                      $ cat 16.txt
                      This is file 16.


                      Put the files into a variable and open the file by an index.



                      $ files=(*)
                      $ xdg-open "${files[12]}"
                      # Opens 12.txt in a text editor, which reads "This is file 12."


                      Replace 12 with the index you're trying to open.






                      share|improve this answer


























                      • I'd prefer {00..20} instead of $(seq -w 0 20) because it's just one external process less to spawn. I'm not sure about portability though. Might be a bash-ism.. ;-)

                        – Oscar
                        10 hours ago
















                      1














                      Make some files:



                      $ for i in $(seq -w 0 20); do echo "This is file $i." > $i.txt; done
                      $ ls
                      00.txt 03.txt 06.txt 09.txt 12.txt 15.txt 18.txt
                      01.txt 04.txt 07.txt 10.txt 13.txt 16.txt 19.txt
                      02.txt 05.txt 08.txt 11.txt 14.txt 17.txt 20.txt
                      $ cat 16.txt
                      This is file 16.


                      Put the files into a variable and open the file by an index.



                      $ files=(*)
                      $ xdg-open "${files[12]}"
                      # Opens 12.txt in a text editor, which reads "This is file 12."


                      Replace 12 with the index you're trying to open.






                      share|improve this answer


























                      • I'd prefer {00..20} instead of $(seq -w 0 20) because it's just one external process less to spawn. I'm not sure about portability though. Might be a bash-ism.. ;-)

                        – Oscar
                        10 hours ago














                      1












                      1








                      1







                      Make some files:



                      $ for i in $(seq -w 0 20); do echo "This is file $i." > $i.txt; done
                      $ ls
                      00.txt 03.txt 06.txt 09.txt 12.txt 15.txt 18.txt
                      01.txt 04.txt 07.txt 10.txt 13.txt 16.txt 19.txt
                      02.txt 05.txt 08.txt 11.txt 14.txt 17.txt 20.txt
                      $ cat 16.txt
                      This is file 16.


                      Put the files into a variable and open the file by an index.



                      $ files=(*)
                      $ xdg-open "${files[12]}"
                      # Opens 12.txt in a text editor, which reads "This is file 12."


                      Replace 12 with the index you're trying to open.






                      share|improve this answer















                      Make some files:



                      $ for i in $(seq -w 0 20); do echo "This is file $i." > $i.txt; done
                      $ ls
                      00.txt 03.txt 06.txt 09.txt 12.txt 15.txt 18.txt
                      01.txt 04.txt 07.txt 10.txt 13.txt 16.txt 19.txt
                      02.txt 05.txt 08.txt 11.txt 14.txt 17.txt 20.txt
                      $ cat 16.txt
                      This is file 16.


                      Put the files into a variable and open the file by an index.



                      $ files=(*)
                      $ xdg-open "${files[12]}"
                      # Opens 12.txt in a text editor, which reads "This is file 12."


                      Replace 12 with the index you're trying to open.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 12 hours ago

























                      answered Mar 22 at 15:34









                      user1717828user1717828

                      196111




                      196111













                      • I'd prefer {00..20} instead of $(seq -w 0 20) because it's just one external process less to spawn. I'm not sure about portability though. Might be a bash-ism.. ;-)

                        – Oscar
                        10 hours ago



















                      • I'd prefer {00..20} instead of $(seq -w 0 20) because it's just one external process less to spawn. I'm not sure about portability though. Might be a bash-ism.. ;-)

                        – Oscar
                        10 hours ago

















                      I'd prefer {00..20} instead of $(seq -w 0 20) because it's just one external process less to spawn. I'm not sure about portability though. Might be a bash-ism.. ;-)

                      – Oscar
                      10 hours ago





                      I'd prefer {00..20} instead of $(seq -w 0 20) because it's just one external process less to spawn. I'm not sure about portability though. Might be a bash-ism.. ;-)

                      – Oscar
                      10 hours ago











                      0














                      This is probably the simplest answer that directly answers the question.
                      try the following:



                      touch file-1 file-2 file-3


                      Let's say we want to open (or edit) the second file, we can do the following:



                      echo `ls` | cut -d' ' -f2


                      this will output the name of the second file, which we can use as input to the command we want to perform, for example:



                      cat $( echo `ls` | cut -d' ' -f2 )


                      will output the content of the second file.




                      note that you can change the order in which the files are printed by ls, by tweaking ls arguments, see man ls for details.




                      [UPDATE] this assumes that you have no white-spaces in file names,

                      thanks @wjandrea for your observation.






                      share|improve this answer










                      New contributor




                      HElanabi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.
















                      • 1





                        This will fail for filenames that contain spaces. This answer gets around that, but it's still a bad idea to parse ls. Also backticks are deprecated. Use $() instead.

                        – wjandrea
                        2 days ago
















                      0














                      This is probably the simplest answer that directly answers the question.
                      try the following:



                      touch file-1 file-2 file-3


                      Let's say we want to open (or edit) the second file, we can do the following:



                      echo `ls` | cut -d' ' -f2


                      this will output the name of the second file, which we can use as input to the command we want to perform, for example:



                      cat $( echo `ls` | cut -d' ' -f2 )


                      will output the content of the second file.




                      note that you can change the order in which the files are printed by ls, by tweaking ls arguments, see man ls for details.




                      [UPDATE] this assumes that you have no white-spaces in file names,

                      thanks @wjandrea for your observation.






                      share|improve this answer










                      New contributor




                      HElanabi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.
















                      • 1





                        This will fail for filenames that contain spaces. This answer gets around that, but it's still a bad idea to parse ls. Also backticks are deprecated. Use $() instead.

                        – wjandrea
                        2 days ago














                      0












                      0








                      0







                      This is probably the simplest answer that directly answers the question.
                      try the following:



                      touch file-1 file-2 file-3


                      Let's say we want to open (or edit) the second file, we can do the following:



                      echo `ls` | cut -d' ' -f2


                      this will output the name of the second file, which we can use as input to the command we want to perform, for example:



                      cat $( echo `ls` | cut -d' ' -f2 )


                      will output the content of the second file.




                      note that you can change the order in which the files are printed by ls, by tweaking ls arguments, see man ls for details.




                      [UPDATE] this assumes that you have no white-spaces in file names,

                      thanks @wjandrea for your observation.






                      share|improve this answer










                      New contributor




                      HElanabi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.










                      This is probably the simplest answer that directly answers the question.
                      try the following:



                      touch file-1 file-2 file-3


                      Let's say we want to open (or edit) the second file, we can do the following:



                      echo `ls` | cut -d' ' -f2


                      this will output the name of the second file, which we can use as input to the command we want to perform, for example:



                      cat $( echo `ls` | cut -d' ' -f2 )


                      will output the content of the second file.




                      note that you can change the order in which the files are printed by ls, by tweaking ls arguments, see man ls for details.




                      [UPDATE] this assumes that you have no white-spaces in file names,

                      thanks @wjandrea for your observation.







                      share|improve this answer










                      New contributor




                      HElanabi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.









                      share|improve this answer



                      share|improve this answer








                      edited yesterday





















                      New contributor




                      HElanabi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.









                      answered 2 days ago









                      HElanabiHElanabi

                      593




                      593




                      New contributor




                      HElanabi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.





                      New contributor





                      HElanabi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.






                      HElanabi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.








                      • 1





                        This will fail for filenames that contain spaces. This answer gets around that, but it's still a bad idea to parse ls. Also backticks are deprecated. Use $() instead.

                        – wjandrea
                        2 days ago














                      • 1





                        This will fail for filenames that contain spaces. This answer gets around that, but it's still a bad idea to parse ls. Also backticks are deprecated. Use $() instead.

                        – wjandrea
                        2 days ago








                      1




                      1





                      This will fail for filenames that contain spaces. This answer gets around that, but it's still a bad idea to parse ls. Also backticks are deprecated. Use $() instead.

                      – wjandrea
                      2 days ago





                      This will fail for filenames that contain spaces. This answer gets around that, but it's still a bad idea to parse ls. Also backticks are deprecated. Use $() instead.

                      – wjandrea
                      2 days ago










                      yh yeah is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      yh yeah is a new contributor. Be nice, and check out our Code of Conduct.













                      yh yeah is a new contributor. Be nice, and check out our Code of Conduct.












                      yh yeah is a new contributor. Be nice, and check out our Code of Conduct.
















                      Thanks for contributing an answer to Ask Ubuntu!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1127755%2fopen-a-doc-from-terminal-but-not-by-its-name%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Masuk log Menu navigasi

                      Identifying “long and narrow” polygons in with PostGISlength and width of polygonWhy postgis st_overlaps reports Qgis' “avoid intersections” generated polygon as overlapping with others?Adjusting polygons to boundary and filling holesDrawing polygons with fixed area?How to remove spikes in Polygons with PostGISDeleting sliver polygons after difference operation in QGIS?Snapping boundaries in PostGISSplit polygon into parts adding attributes based on underlying polygon in QGISSplitting overlap between polygons and assign to nearest polygon using PostGIS?Expanding polygons and clipping at midpoint?Removing Intersection of Buffers in Same Layers

                      Старые Смолеговицы Содержание История | География | Демография | Достопримечательности | Примечания | НавигацияHGЯOLHGЯOL41 206 832 01641 606 406 141Административно-территориальное деление Ленинградской области«Переписная оброчная книга Водской пятины 1500 года», С. 793«Карта Ингерманландии: Ивангорода, Яма, Копорья, Нотеборга», по материалам 1676 г.«Генеральная карта провинции Ингерманландии» Э. Белинга и А. Андерсина, 1704 г., составлена по материалам 1678 г.«Географический чертёж над Ижорскою землей со своими городами» Адриана Шонбека 1705 г.Новая и достоверная всей Ингерманландии ланткарта. Грав. А. Ростовцев. СПб., 1727 г.Топографическая карта Санкт-Петербургской губернии. 5-и верстка. Шуберт. 1834 г.Описание Санкт-Петербургской губернии по уездам и станамСпецкарта западной части России Ф. Ф. Шуберта. 1844 г.Алфавитный список селений по уездам и станам С.-Петербургской губернииСписки населённых мест Российской Империи, составленные и издаваемые центральным статистическим комитетом министерства внутренних дел. XXXVII. Санкт-Петербургская губерния. По состоянию на 1862 год. СПб. 1864. С. 203Материалы по статистике народного хозяйства в С.-Петербургской губернии. Вып. IX. Частновладельческое хозяйство в Ямбургском уезде. СПб, 1888, С. 146, С. 2, 7, 54Положение о гербе муниципального образования Курское сельское поселениеСправочник истории административно-территориального деления Ленинградской области.Топографическая карта Ленинградской области, квадрат О-35-23-В (Хотыницы), 1930 г.АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1933, С. 27, 198АрхивированоАдминистративно-экономический справочник по Ленинградской области. — Л., 1936, с. 219АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1966, с. 175АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1973, С. 180АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1990, ISBN 5-289-00612-5, С. 38АрхивированоАдминистративно-территориальное деление Ленинградской области. — СПб., 2007, с. 60АрхивированоКоряков Юрий База данных «Этно-языковой состав населённых пунктов России». Ленинградская область.Административно-территориальное деление Ленинградской области. — СПб, 1997, ISBN 5-86153-055-6, С. 41АрхивированоКультовый комплекс Старые Смолеговицы // Электронная энциклопедия ЭрмитажаПроблемы выявления, изучения и сохранения культовых комплексов с каменными крестами: по материалам работ 2016-2017 гг. в Ленинградской области