Results 1 to 4 of 4
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 ...
- 03-18-2007 #1Just Joined!
- Join Date
- Mar 2007
- Posts
- 2
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?
- 03-19-2007 #2Linux User
- Join Date
- Aug 2005
- Posts
- 408
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.)
- 03-19-2007 #3Just Joined!
- Join Date
- Mar 2007
- Posts
- 2
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.
- 03-19-2007 #4Linux User
- Join Date
- Aug 2005
- Posts
- 408
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:
(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)?)Code:ls | head -1 | xargs nano


Reply With Quote