![]() |
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 |
| how to filter out some paragraphs in a file | cnlhap | Shell Programming and Scripting | 7 | 08-19-2008 03:03 PM |
| To cut entire column from a file and apend it to another file as another column | sakthifire | Shell Programming and Scripting | 4 | 06-25-2008 04:27 AM |
| How to check Null values in a file column by column if columns are Not NULLs | Mandab | Shell Programming and Scripting | 7 | 03-15-2008 09:57 AM |
| File filter | Dastard | Shell Programming and Scripting | 3 | 09-06-2007 01:50 PM |
| filter based on column value | rraajjiibb | Shell Programming and Scripting | 2 | 05-25-2004 09:09 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
filter out certain column from a file
Hi all,
I have this file, how can i remove the ID Number and Cardholder Name from the file ? Code:
[?25h[2J[?4l[?1l[0m[1;24r[?3h[?3h
Mon Apr 4 2005 5:12PM
Page 1
Location Log Recall Report
Sun Apr 3 2005 11:06AM to Mon Apr 4 2005 12:00AM
__________________________________________________________________________________________________________________________________
| |
| Locations: 599 Parker's II 016869517 Transactions: Valid Transaction Type: All Reader Status: Online |
|__________________________________________________________________________________________________________________________________|
| | |T| |Reader| | | |M|O|O| | Trans |
| Date | Time |P| Location | Name | ID Number | Cardholder Name | Action |N|F|K| Reason |Amount |
__________________________________________________________________________________________________________________________________
|04/03/05|01:43PM|1|Parker II |Park 2|000735219 |Regnier, Michael |Credit/Debit Spending| | |Y| | 10.00|
|04/03/05|06:01PM|1|Parker II |Park 2|000676759 |Stevenson, Aren |Credit/Debit Spending| | |Y| | 11.32|
|04/03/05|07:00PM|1|Parker II |Park 2|000728866 |Culbreth, Anna |Credit/Debit Spending| | |Y| | 4.06|
__________________________________________________________________________________________________________________________________
Blackboard Inc. End
Thanks CT |
|
||||
|
I never have a need to write such a thing and don't write anything complex in awk but here is a stab and I think it meets your requirements (they were ambiguous in my mind so you have two solutions). I am absolutly certain this is too clumsy and can be written more elegantly.
If you are trying to blank the two fields: Code:
awk -F\| '
NF != 15 {
print $0
}
NF == 15 && $4 == "T" || $4 == "P" {
print $0
}
NF==15 && $4 != "T" && $4 != "P" {
printf ("%s%s%s\n",substr($0,1,38)," | |",substr($0,80))
}' yourreportfile.rpt
Code:
awk -F\| '
NF==15 && $4 != "T" && $4 != "P" {
printf ("%s\t%s\n",$7,$8)
}' yourreportfile.rpt
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|