![]() |
|
|
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 |
| Displaying lines of a file where the second field matches a pattern | LordJezoX | Shell Programming and Scripting | 3 | 05-20-2009 09:00 AM |
| replace a column in a file if it matches certain pattern | Krrishv | Shell Programming and Scripting | 6 | 03-12-2009 05:16 AM |
| Print line if first Field matches a pattern | Raynon | Shell Programming and Scripting | 2 | 01-08-2009 06:07 AM |
| awk to count pattern matches | npatwardhan | Shell Programming and Scripting | 16 | 12-13-2008 12:20 PM |
| Extract if pattern matches | Raynon | Shell Programming and Scripting | 20 | 10-29-2007 04:44 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Code:
for name in `ls root/log`
do
if [[ $name =~ [0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9] ]]; then
DATE=`echo $name |cut -d\. -f2`
fi
if [[ $name =~ [0-9][0-9]\.[0-9][0-9]\.[0-9][0-9] ]]; then
DATE=`echo $name |awk -F[\.] '{print $3"."$4"."$5}'`
fi
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|