cmd to view only directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cmd to view only directories
# 8  
Old 04-06-2006
have u tried dir command
type:- I cant understand what u looking for??? but i guess thats it...or u want to see files within dir also???


dir
# 9  
Old 04-06-2006
do u want this??

ls -ld mails
# 10  
Old 05-05-2006
Displays all the directories (current location)

Append this in profile:
alias lsd='ls -1F $* | grep '/$' '

type
lsd

This will display all the directories.
E.g.:-
dir_a/
dir_b/
mails/
# 11  
Old 05-05-2006
Quote:
Originally Posted by blazingrock4u
Append this in profile:
alias lsd='ls -1F $* | grep '/$' '

type
lsd

This will display all the directories.
E.g.:-
dir_a/
dir_b/
mails/
Dude! That's a nice little alias.

I'm an alias junkie.. I'll make sure I add that one Smilie

Cheers
# 12  
Old 05-05-2006
The given alias is quite ok for listings of the $PWD.
But if I remember correctly aliases (or better alii) are parameter ignorant.
If you wish to pass parameters you need to define a shell function.
For instance you could put this in your .shrc file.
Code:
lsd() { ls -p $*|grep /\$; }

Then you could say e.g.
lsd /etc /var
# 13  
Old 05-05-2006
Of course the classic way to list directories is simply to use find
e.g. for a recursive search

find /var -type d

But you could restrict the descent to inodes of the same filesystem

find /var -xdev -type d

Or even limit the depth of descent

find /var -maxdepth 1 -type d

But better consult your Unix's manpage of find because despite
a common denominator the different finds all deviate slightly in their scope and syntax.
Probably the widest functionality is offered by GNU find,
as is part of findutils of Linux distros.

Note also, if you run find with restricted permissions as far as read and execute
of dirs is concerned that it's probably advisable to redirect stderr to /dev/null
to prevent error messages cluttering your find results.
# 14  
Old 05-08-2006
Tools

Quote:
Originally Posted by buffoonix
The given alias is quite ok for listings of the $PWD.
But if I remember correctly aliases (or better alii) are parameter ignorant.
If you wish to pass parameters you need to define a shell function.
For instance you could put this in your .shrc file.
Code:
lsd() { ls -p $*|grep /\$; }

Then you could say e.g.
lsd /etc /var

I've never had a problem passing arg's to aliases. Consider the RH default, which aliases 'ls' to 'ls --color'..

Perhaps the problem is a "shell specific", one. In which case, we could chalk it up to another example of of how much bash RULES. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. What is on Your Mind?

Moving from Desktop View to Mobile View

See attached video for a demo on how to move back and forth from the desktop view to the mobile view. Currently this only works for the home page, but I will work on some new PHP code in the future to make this work with the page we are currently on. Edit: The issue with making every page ... (2 Replies)
Discussion started by: Neo
2 Replies

2. Solaris

Giving read write permission to user for specific directories and sub directories.

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies

3. Shell Programming and Scripting

Help with tar cmd for directories

Hi, I'm working on HP-UX B.11.23 64bit. I tried to tar couple of directories but failed to do so. $ tar -cvf tar_file_name -C /dir1 /dir2 the -C is for directories as mentioned in the man pages. But still unable to create a tar file having directories and sub-directories. Requesting help in... (1 Reply)
Discussion started by: sam_bd
1 Replies

4. UNIX for Dummies Questions & Answers

List the directories, having given pattern in the directories name, sorted by creation date

It is for HP-Unix B.11.31. Requirement: 1. List the directories, having given pattern in the directories name, sorted by creation date. Example: Directories with name "pkg32*" or "pkg33*" 2. On the output of 1. list the directories by creation date as sort order, with creation date... (2 Replies)
Discussion started by: Siva SQL
2 Replies

5. Shell Programming and Scripting

Perl open(CMD, "cmd |"); buffering problem..

Hello, There's a third-party application's command that shows the application's status like "tail -f verybusy.log". When use the command, the output comes every 1-sec. but when it goes in a script below the output comes every 8-sec...What is the problem and how can I fix it? open(CMD,... (2 Replies)
Discussion started by: Shawn, Lee
2 Replies

6. Shell Programming and Scripting

Unix cmd prompt how to get old cmd run?

Hi, I am using SunOS I want to serch my previous command from unix prompt (like on AIX we can search by ESC -k) how to get in SunOs urgent help require. (10 Replies)
Discussion started by: RahulJoshi
10 Replies

7. Shell Programming and Scripting

Script for parsing directories one level and finding directories older than n days

Hello all, Here's the deal...I have one directory with many subdirs and files. What I want to find out is who is keeping old files and directories...say files and dirs that they didn't use since a number of n days, only one level under the initial dir. Output to a file. A script for... (5 Replies)
Discussion started by: ejianu
5 Replies

8. UNIX for Dummies Questions & Answers

man <cmd> >> cmd.txt

I've noticed most of my postings here are because of syntax errors. So I want to begin compiling a large txt file that contains all the "man <cmd>" of the commands I most have problems with. I ran a "man nawk >> nawk.txt" but it included a header/footer on each "page". Anyone know how I'd be... (6 Replies)
Discussion started by: yongho
6 Replies
Login or Register to Ask a Question