Operating System - HP-UX
1826428 Members
3440 Online
109692 Solutions
New Discussion

Re: UNIX equivalent command

 
SOLVED
Go to solution
Alex Rauket
Occasional Contributor

UNIX equivalent command

Is there a UNIX command that will list a directory's contents in a single column, but not list directories, much like the dos

dir /A-D /B

command?

Thanks
4 REPLIES 4
Rodney Hills
Honored Contributor
Solution

Re: UNIX equivalent command

How about-
find . ! -type d -print

or

ls -p | grep -v "/$"

HTH

-- Rod Hills
There be dragons...
Jim Turner
HPE Pro

Re: UNIX equivalent command

Well, of course "ls -1" (that's a numeral 'one' after the dash) gives you a single column output, but it includes directories.

I reckon you could try something like
ls -l | grep -v ^d | awk '{print $9}'

That would exclude directories but still include things other than regular files like char and block devices, sockets, links, etc.

Merry Christmas,
Jim
Alex Rauket
Occasional Contributor

Re: UNIX equivalent command

Thanks guys. That solved the problem nicely.

Merry Christmas and Happy New Year!
Jeff_Traigle
Honored Contributor

Re: UNIX equivalent command

Not an option on ls that will. Can do something like this for the same result though:

ls -al | grep -v ^d | awk '{if ($9 != "") print $9}'
--
Jeff Traigle