![]() |
|
|
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 |
| Passing global variable to a function which is called by another function | sars | Shell Programming and Scripting | 4 | 06-30-2008 12:39 PM |
| function help | coolkid | Shell Programming and Scripting | 2 | 05-01-2008 02:47 PM |
| Log function | Ernst | Shell Programming and Scripting | 17 | 03-19-2007 12:31 PM |
| Function within function (Recurance) | chassis | UNIX for Dummies Questions & Answers | 2 | 09-19-2006 10:32 AM |
| How to convert the "select" function into a "poll" function | rbolante | High Level Programming | 1 | 07-10-2001 11:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
awk with function ?? please, help :(
Here is my test.in file
Case Modify 10001 20002 30003 40004|Report Create 3417176211|Case Modify 10002 20002 30003 40004| Script: Remove.ksh Quote:
$ cat test.in Case Modify 10001 20002 30003 40004|Report Create 3417176211|Case Modify 10002 20002 30003 40004| $ remove.ksh "Case Modify 10002" Case Modify 10001 20002 30003 40004|Report Create 3417176211| $ =========== How do I use this remove.ksh and write as a function so it can remove what I want #!/bin/ksh cd ./intermediate cat out.log | awk -F"|" ' function writeit() { printf "%s,%s\,%s\n\n",outputId,TempDateTime,outputAction; outputAction = ""; return } { id=$1; datetime=$2; location=$3; ani=$4; ext=$5; calLength=$6; action = $7; lastacct=""; ............ if (action ~ /Modify/) { ## open if Modify outputAction = action "|"; type = substr(action,1,index(action,"Modify")-2); mainkey = substr(action,index(action,"Modify")+7,index(substr(action,index(action,"Modify")+7,20)," ")-1); searchspec1 = type " " mainkey; searchspec2 = type " Modify " mainkey; searchspec3 = type " Access " mainkey; if ((outputAction ~ searchspec1) || (outputAction ~ searchspec2)) { } else if ((outputAction ~ searchspec3)) { how to apply remove.ksh here to remove searchspec3 in outputAction ## add a funtion to call if outputAction contain searchspec3 then remove it from outputAction like ## outputAction ='Case Modify 10001 20002 30003 40004|Report Create 3417176211|Case Access 10001 10003 1004|Case Modify 10002 20002 30003 40004|' ## searchspec3 = 'Case Access 10001' ##then the outputAction ='Case Modify 10001 20002 30003 40004|Report Create 3417176211|Case Modify 10002 20002 30003 40004|' [/color] outputAction = outputAction action "|"; } else { outputAction = outputAction action "|"; } } else if (action ~ /Access/) { type = substr(action,1,index(action,"Access")-2); mainkey = substr(action,index(action,"Access")+7,index(substr(action,index(action,"Access")+7,20)," ")); searchspec1 = type mainkey; searchspec2 = type "Modify " mainkey; searchspec3 = type "Access " mainkey; if ((outputAction ~ "searchspec1") || (outputAction ~ "searchspec2") || (outputAction ~ "searchspec3")) { } else { outputAction = outputAction action "|"; } } else if (action ~ /CDxAcct/) { acct = substr(action,9,10); if (acct != lastacct) { outputAction = outputAction "CDxAcct=" acct "|"; lastacct = acct; } } else if (action ~ /ID/) { type = substr(action,1,index(action," ")-1); mainkey = substr(action,index(action," ")+1,index(substr(action,index(action," ")+1,20)," ")-1); searchspec1 = type " " mainkey; searchspec2 = type "Modify " mainkey; searchspec3 = type "Access " mainkey; if (outputAction ~ searchspec1) { } else if (outputAction ~ searchspec2) { how to apply remove.ksh here to remove searchspec2 in outputAction ## add a funtion to call if outputAction contain searchspec2 then remove it from outputAction like ## outputAction ='Case Modify 10001 20002 30003 40004|Report Create 3417176211|Case Access 10001 10003 1004|Case Modify 10002 20002 30003 40004|' ## searchspec2 = 'Case Modify 10001' ##then the outputAction ='Report Create 3417176211|Case Access 10001 10003 1004|Case Modify 10002 20002 30003 40004|' outputAction = outputAction action "|"; } else if (outputAction ~ searchspec3) { how to apply remove.ksh here to remove searchspec3 in outputAction ## add a funtion to call if outputAction contain searchspec3 then remove it from outputAction like ## outputAction ='Case Modify 10001 20002 30003 40004|Report Create 3417176211|Case Access 10001 10003 1004|Case Modify 10002 20002 30003 40004|' ## searchspec3 = 'Case Access 10001' ##then the ='Case Modify 10001 20002 30003 40004|Report Create 3417176211|Case Modify 10002 20002 30003 40004|' outputAction = outputAction action "|"; } else { outputAction = outputAction action "|"; } } else { if (action == "CTI-Begin Call" || action == "CTI-CallTimer") { } else { outputAction = outputAction action "|"; } } } } END { writeit(); }' ========================= out.log example |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|