![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| listing of directories with / at end...without ls -F | vasanthan | UNIX for Dummies Questions & Answers | 10 | 04-16-2008 05:34 AM |
| listing of directories with / ...not to use ls -F | vasanthan | UNIX for Advanced & Expert Users | 1 | 04-16-2008 04:20 AM |
| Listing directories and sub directories | jinxor | UNIX for Advanced & Expert Users | 3 | 03-11-2008 10:27 AM |
| Listing Unique directories. | deepakwins | UNIX for Dummies Questions & Answers | 2 | 01-23-2008 06:14 PM |
| files and directories listing | bbolson | UNIX for Dummies Questions & Answers | 1 | 12-11-2001 01:30 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Listing directories and ${1:+$1/}*
Hi
I have 2 questions: Q1 - What does ${1:+$1/}* mean? I guess it lists all files in current directory - Could any one explain how this expression works? Q2 - I am trying to list directories only in current path - I know that ls could be used but I thought I'd give find a try. I need to list only high level directories (no sub directories or files) find has option -type d however, the following command always lists sub-directories: find . -type d I tried to use maxdepth as in find . -type d maxdepth 0 but that gives me syntax error. So my Q2 is: How to use fiind command to list top level directories only? Thanks much. |
|
|||||
|
Regarding ${1:+1\}*
In Korn shell you can use expressions such as this to set default values for variables. The above statement checks to see that if $1 (the first input variable) is set, if it is then $1\* is substituted. Can you post the complete line in your script where this is used? Also, there are other builtins, please see the botton of this thread Regarding listing directories using find. Well thats sort of using a hammer to break an egg Plus, by default, find is recursive in nature. Try using ls | grep ^d or something like that. |
|
||||
|
Thanks
Thanks for your help guys.
As per google's inquiry about the context, it appeared in a ksh script that goes through files and directories and does operations on them, it looked like this: for filename in ${1:+$1/}*; do .... done I personlay think that this form of coding in ksh is not comfortable. It is more compact but then again not instantly readable... |
|
|||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|