LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-22-2007, 12:10 AM   #1
szahri
LQ Newbie
 
Registered: Mar 2005
Posts: 11

Rep: Reputation: 0
Listing files in a directory without ls and find?


Hi all,
Is there another way to list files in a directory without ls and find? I couldnt think of anything else..thanks!
 
Old 03-22-2007, 12:23 AM   #2
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
How about 'dir' ?
And if you want the hidden ones too, use 'dir -a'
 
Old 03-22-2007, 12:25 AM   #3
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 61
You can open the directory with a text editor.

Why don't you have ls or find?

--Ian
 
Old 03-22-2007, 12:48 AM   #4
szahri
LQ Newbie
 
Registered: Mar 2005
Posts: 11

Original Poster
Rep: Reputation: 0
Hi,
Thanks for the answers!

Is it possible to open a directory with a text editor..? wouldnt it complain of it being a directory instead of file (or something like that?

Thanks again
 
Old 03-22-2007, 12:54 AM   #5
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 61
Everything in Linux is a file. A directory is a file that contains a list of files.

If I open my $HOME/Desktop directory in vi:
Code:
vi Desktop/
I get the following:
Code:
" ============================================================================
" Netrw Directory Listing                                        (netrw v98)
"   /home/ian/Desktop
"   Sorted by      name
"   Sort sequence: [\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$
"   Quick Help: <F1>:help  -:go up dir  D:delete  R:rename  s:sort-by  x:exec
" ============================================================================
../
./
Christmas06/
European Holiday/
Misc/
Who says men don't remember anniversaries.doc
iceweasel.desktop
mythtv.desktop
xnc-gnome2.desktop
--Ian
 
Old 03-22-2007, 12:59 AM   #6
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
dir > filename && kate filename

There may be a simpler (less wordy) way, but this puts the directory listing into 'filename' and then opens 'filename' in kate.

EDIT: Ya, like iBall did

Last edited by GrapefruiTgirl; 03-22-2007 at 01:00 AM.
 
Old 03-22-2007, 01:11 AM   #7
dubya
Member
 
Registered: Mar 2004
Location: Kitchener, Ontario, Canada
Posts: 386

Rep: Reputation: 30
Here's the simplest way I know:
Code:
echo *
 
Old 03-22-2007, 03:51 AM   #8
doc.nice
Member
 
Registered: Oct 2004
Location: Germany
Distribution: Debian
Posts: 274

Rep: Reputation: 34
but really: why does one need this? I'm very curious...
 
Old 03-22-2007, 03:58 AM   #9
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 61
Quote:
Originally Posted by dubya
Here's the simplest way I know:
Code:
echo *
That's an interesting one
 
Old 03-22-2007, 09:25 AM   #10
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Szahri,
Please answer IBall and doc.nice! Why do you need ways other than ls and find? Is this homework?

BTW, I've actually had to use echo * in the past, when I had messed up a Unix bad enough that ls wouldn't run.
 
Old 03-22-2007, 06:30 PM   #11
axobeauvi
Member
 
Registered: Apr 2003
Posts: 128

Rep: Reputation: 16
could always open a gui file browser
 
Old 03-23-2007, 03:12 AM   #12
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,604

Rep: Reputation: 47
sounds like homework to me

dir is an alias, no? so does it count like ls
 
  


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
How to find grand total size of all files in a directory fakhrul Red Hat 4 04-17-2010 12:28 AM
Using Bash, Find script files in a directory or subdirectories within... ray5_83 Programming 4 10-10-2008 07:42 PM
How to find the date for all the files in a directory Uday123 AIX 6 02-23-2006 08:26 PM
GTKMM - Compilation Errors - Can't find files or Directory sixtensixone Programming 3 04-06-2005 10:06 AM
listing files in a directory Linh Programming 7 05-17-2004 04:35 AM


All times are GMT -5. The time now is 12:28 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration