|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX Desktop for Dummies Questions & Answers Discuss UNIX and Linux user interfaces like GNOME, KDE, CDE, and Open Office here. All UNIX and Linux Newbies Welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
[SOLVED] find command match pattern
Hello, I would like to ask you, how to match directory names. I need to find only directories, which are created only from numbers and doesn't include any letters. I used command Code:
find $AC_WORKDIR/work_archive/test/$dirs_years -maxdepth 1 -name \[0-9]\* -print If I have dirs like 12 12ab ab12 it gives dirs 12, 12ab. I need only dir 12. Thank you for your answer |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
The awk script below will print all directory names in or under $AC_WORKDIR/work_archive/test/$dirs_years with names that only contain digits. You can put back in the maxdepth clause if you only want directories in (not under) that directory. (Note, however, that -maxdepth is not required by the standards and is not present in all implementations of the find utility.) Code:
find $AC_WORKDIR/work_archive/test/$dirs_years -type d ! -name '*[!0-9]*' Last edited by Don Cragun; 09-22-2012 at 07:16 PM.. Reason: Add note about maxdepth |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Try the below example: Code:
$ cd tmp $ ls -l drwxr-xr-x+ 1 Sep 22 17:33 1 drwxr-xr-x+ 1 Sep 22 17:34 12 drwxr-xr-x+ 1 Sep 22 17:34 12ab drwxr-xr-x+ 1 Sep 22 17:34 2 drwxr-xr-x+ 1 Sep 22 17:34 ab12 drwxr-xr-x+ 1 Aug 22 19:14 txt2regex-0.8 $ find . -maxdepth 1 -regex "./[0-9]*" ./1 ./12 ./2 |
|
#4
|
|||
|
|||
|
Thank you for your help
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Solved] weird in find -exec command | lsy | UNIX for Dummies Questions & Answers | 12 | 09-03-2012 08:09 AM |
| [Solved] Find duplicate and add pattern in sed/awk | lolworlds | Shell Programming and Scripting | 0 | 02-03-2012 06:54 AM |
| [Solved] Assistance with find command please | Condmach | UNIX for Dummies Questions & Answers | 2 | 10-25-2011 07:40 AM |
| fetch last line no form file which is match with specific pattern by grep command | Himanshu_soni | Shell Programming and Scripting | 13 | 02-01-2011 06:37 AM |
| find: No match due to find command being argument | mst3k4l | Shell Programming and Scripting | 2 | 08-10-2009 09:48 AM |
|
|