![]() |
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 |
| get substr? | syamkp | Shell Programming and Scripting | 6 | 03-31-2008 02:08 AM |
| awk or substr | ramky79 | UNIX for Dummies Questions & Answers | 3 | 03-13-2007 08:18 PM |
| Substr | deepakwins | UNIX for Dummies Questions & Answers | 9 | 02-14-2007 12:58 AM |
| Using substr | Klashxx | Shell Programming and Scripting | 2 | 05-08-2006 07:58 AM |
| How to use awk substr ? | sabercats | Shell Programming and Scripting | 1 | 02-10-2006 07:01 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
awk substr
Hi
I have multiple files that name begins bidb_yyyymm. (yyyymm = current year month of file creation). What I want to do is look at the files and where yyyymm is older than 1 month I want to remove the file from the server. I was looking at looping through the files and getting the yyyymm from the filename and comparing it to the cuurent dates yyyymm. for file in `ls *.gz` do now=`date '+%Y%m'` fileext=awk substr($file,6,6) if [$now-$fileext] <> 0 then rm $file fi I was looking at awk substr to get the part of the filename i require but could not get this to work. Has anyone done anything like this before or can point me in the right direction to achieve my objectives. Cheers Gary |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|