LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-05-2005, 01:33 PM   #1
ar3ol
LQ Newbie
 
Registered: Dec 2005
Posts: 4

Rep: Reputation: 0
HELP, sorting files by name with environment


Hi.
I created a php page that looks at the files in a dir in a linux box and displays them. my prob is that the files are being sorted by the way linux is set (date/time) and i wnat them sorted by name.

i read that if i want to sort the files by name instead of date/time, i need to change the environmental variables for that dir in linux but i dont know how to do that! HELP!

can someone please help me out?

thank you.
 
Old 12-05-2005, 01:36 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi,

And welcome to LQ!

What are you doing within PHP to retrieve the directory listing?



Cheers,
Tink
 
Old 12-05-2005, 02:01 PM   #3
ar3ol
LQ Newbie
 
Registered: Dec 2005
Posts: 4

Original Poster
Rep: Reputation: 0
thanks. here is my script:


------------------------------------
$dirname = "/asf/asfd/";
$dir = opendir($dirname);

while(false != ($file = readdir($dir))){

if($file != ".") and ($file != "..")){

$file_list .= $file."<br>";

}

}

closedir($dir);

echo $file_list;
------------------------------------

thanks for the help.
 
Old 12-05-2005, 02:58 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Have a look at
http://www.php.net/manual/en/function.readdir.php
and search that page for sort :}


Cheers,
Tink
 
Old 12-05-2005, 03:08 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
My apologies, that wasn't what you're after at all ... in this case I'd
use
system( ls -1tr, $variable);


Cheers,
Tink
 
Old 12-05-2005, 04:01 PM   #6
ar3ol
LQ Newbie
 
Registered: Dec 2005
Posts: 4

Original Poster
Rep: Reputation: 0
HA!!!
thanks alot! wasnt expecting that.

you rock!
 
Old 12-05-2005, 04:03 PM   #7
ar3ol
LQ Newbie
 
Registered: Dec 2005
Posts: 4

Original Poster
Rep: Reputation: 0
well, yeah, the php array thing works fine! thanks! but its also good to know the linux command. i used the php solution.

much appreciated.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting data. unreal128 Linux - Software 1 09-20-2005 06:31 PM
sorting a map (C++) Thinking Programming 6 09-13-2005 04:52 PM
Sorting Beppe83 Linux - Software 7 06-21-2004 09:10 AM
which path do the environment variable files reside in ycli00 Linux - General 1 03-03-2004 01:57 AM
Sorting files in Konqueror/File associations/sound in KDE Kelvie Linux - Newbie 9 07-19-2003 01:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration