Created
October 29, 2013 11:39
-
-
Save sriramster/7213127 to your computer and use it in GitHub Desktop.
Awk stuffs, tried to categorize the ~/Downloads folder inside $HOME.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function _categorize(type,dir) { | |
| matches = ($9 ~ type) | |
| if(matches) { | |
| nlines++ | |
| if(dir) { | |
| query = sprintf("cp %s %s",$9,dir) | |
| system(query) | |
| } | |
| } | |
| } | |
| BEGIN { | |
| nlines = 0 | |
| _pattern[1,1]="[*\\.]pdf" | |
| _pattern[1,2]="~/personal/pdf/" | |
| _pattern[2,1]="[*\\.]zip" | |
| _pattern[2,2]="~/personal/zip/" | |
| _pattern[3,1]="[*\\.]tar[.]gz" | |
| _pattern[3,2]="~/personal/tars/" | |
| } | |
| { | |
| _categorize(_pattern[1,1],_pattern[1,2]) | |
| _categorize(_pattern[2,1],_pattern[2,2]) | |
| _categorize(_pattern[3,1],_pattern[3,2]) | |
| } | |
| END { | |
| print nlines | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment