Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Bash sort and open file

    Hey all,

    I'm trying to sort through a listy of text files in a directory and then open a file depending on where it came in the sort, ie I want to open the first file in the sort list. I've tryed all kinds of | and >ing but nothings working.

    Any Ideas?

  2. #2
    Are you sorting the files by regular uses of sort (alphabetical or numerical) and are you just opening in a text editor and are the files consistently named?

    (3 questions there, I guess.)

  3. #3
    Yeh its just the regular sort, havent fully finalised what my naming scheme is but they'll be some scripts in the directory as well (or not depending on how this sort is implemented) The actual files will have some sort of name and with the date in their file name.

    Yehh just opening the files in a text editor, using nano for it.

  4. $spacer_open
  5. #4
    Well, if you just want the first one in a list, the ls command sorts for you, and you could easily do something like this from within the directory where you want to edit the file:
    ls | head -1 | xargs nano
    (Although the above works, for some reason nano within a terminal emulator is sometimes frozen or not frozen when I try it. Works fine with emacs. Can anyone repeat this problem (KDE, Kterm)?)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts