![]() |
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 |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep time and date | ayhanne | Shell Programming and Scripting | 8 | 01-06-2008 09:12 AM |
| grep using date format | ali560045 | Shell Programming and Scripting | 4 | 12-26-2007 08:59 AM |
| grep using date format | ali560045 | Shell Programming and Scripting | 8 | 12-11-2007 06:39 PM |
| grep for date in file | scabral | Shell Programming and Scripting | 2 | 05-29-2007 12:27 PM |
| ls -l | grep $date (failing) | yongho | Shell Programming and Scripting | 1 | 08-01-2005 03:30 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Grep date from ls -l
I have a script which required the month and day as the input
ex : ./script <Month> <date> from this I get the list of files to do further logics. The problem is when I assign these $1 and $2 to variables, and use grep command in the script ls -l |grep "$1 $2" it works fine for two digit dates, but for single digit dates, it doesnt work as Unix leaves an additional space in the ls -l list.. How can get this done. |
|
||||
|
* will match any number of the preceding character. Also it's good to match a space after the last value so that you don't find Apr 22 when you are actually searching for Apr 2, for example.
Code:
ls -l |grep " $1 *$2 " |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|