Eliminate unwanted data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Eliminate unwanted data
# 1  
Old 02-17-2009
Eliminate unwanted data

Hi,

I am stuck on writing a script that reads a file, retains wanted data but discards unwanted data from a CSV file.

This is a sample of my table {not the actual data)

ID Color tel_num Name color2 color3
abcdef green 5551212 jj88 red blue
acbdfe yellow 5552121 88jj blue red
fecdab pink 5556666 34jj black red
fcmlab pink 5556767 78ab black red

I need to keep the green, red and black while eliminating the rest.

thanks
# 2  
Old 02-17-2009
Code:
egrep '(green|red|black)' stuff_in > stuff_out

# 3  
Old 02-17-2009
Okay - it would help if you posted desired output - plus your csv file example is not a csv format - no commas foir example - we cannot tell "fields" apart.
# 4  
Old 02-17-2009
filter wanted data

Thanks for replying. Here is the data again, and I need to export the same file with anything containing "BIO" "PPN" "PNN" "FNN" "NPF" "BCC"

Thanks

dept,course1,course2,course3,course4,course5,course6
CHEM,BIO540,BIO541,BIO16B,MYF17B,SOC203,
BIOL,BIO401,BIO402,BIO910,BIO976,ENG101,SOC633
Math01,BIO25B,MPM21B,MPM22B,MPM26A,,
CHEM,FFN134,FFN509,MERG42B,NPF562,,
Phy01,BDC810,CSPN101,ENG108,,,
GEO001,ENG208,WSO121,WSO199,SCI319,,
Math01,ENG112,BIO540,BIO541,BIOM16C,PLM17C,
Math01,PPN32B,MIL32B,MPF35B,,,
Phy01,BIO604,ENG913,ENG108,HST540,,
Phy01,BIO401,BDL302,BCC134,BIO985,ENG224,PHL206
CHEM,PNN33B,DRA301,DRA42B,PNF36B,GER510,
GEO001,INP900,WSO301,WSO56B,WSO57B,PHL605,
CHEM,FRN631,MYF301,BIO42B,MPF35B,MUS31B,PHL611
GEO001,HST681,WSO301,WSO310,WSO50B,PSY124,
Phy01,BIO201,BIO202,BDG210,BDG211,ENG208,POL208
GEO001,HST604,HST681,WSO301,WSO51B,WSO53B,
IM003,PPN543,PPS42B,PPF549,,,
GEO001,ENG631,WSO112,WSO62B,SOC25B,,
# 5  
Old 02-17-2009
ok -
Code:
grep -v  -e "BIO" -e "PPN" -e "PNN" -e "FNN" -e "NPF" -e "BCC" inputfilename > outputfilename

# 6  
Old 02-17-2009
thanks

Thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Eliminate or ignore asterisks in data when parsing

I have data file that has this in it: data.txt ......... ......... PPJ97**2017PPJ97**2017-03-21-13.35.15.887208********************START ERROR LOGGING****************** PPJ97**2017-03-21-13.35.15.887208** PROMPT APPLICATION ERROR ** PPJ97**2017-03-21-13.35.15.887208** IN TIMESTAMP |... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

Need help to eliminate the records

Hi All, Please help me how to remove the records from the file if it is having more number of fields than the required one, before loading into stage Here is the sample records. File is space delimited one chandu 1121324 CC ( 2 spaces) chandu balu 434657 DD (3 spaces) -- failing due to... (10 Replies)
Discussion started by: bbc17484
10 Replies

3. UNIX for Dummies Questions & Answers

Deleting the unwanted data based on condition

hi i have my input data like this aaa bbb ccc asa dff nmj mnj saa dff oik aax cdx saa oik asq sdf dssi want my output file to be like this mnj saa dff oik aax cdx saa oiki want to retain only those lines which will have oik just below them and i want oik to be as next column to those... (1 Reply)
Discussion started by: anurupa777
1 Replies

4. Shell Programming and Scripting

Help with parsing data with awk , eliminating unwanted data

Experts , Below is the data: --- Physical volumes --- PV Name /dev/dsk/c1t2d0 VG Name /dev/vg00 PV Status available Allocatable yes VGDA 2 Cur LV 8 PE Size (Mbytes) 8 Total PE 4350 Free PE 2036 Allocated PE 2314 Stale PE 0 IO Timeout (Seconds) default --- Physical volumes ---... (5 Replies)
Discussion started by: rveri
5 Replies

5. Shell Programming and Scripting

How to eliminate ^L

Hi, I am trying to create a text file from data retrieved from a query.The data retrieved is having this character '^L' at regular intervals of the data. How can i eliminate this, Please find below the sample data. I tried sed -e "s/\^L//g" to convert it, but with no luck ^LCODE*SERIAL... (11 Replies)
Discussion started by: ramkiran77
11 Replies

6. Shell Programming and Scripting

Compare and eliminate

Could any one help me to compare the date value say at 10th column with sysdate (i.e current date) and if diffrence is more than 50 days then filter them out from the file. The file contain 10000 records. head file 00971502657744 A671FAHP2EW8BG1369172011HRWS contact information ... (6 Replies)
Discussion started by: zooby
6 Replies

7. Shell Programming and Scripting

Eliminate redundant data pairs

Hello Experts: I appeal to you to see if you can help me with a small problem. I have a .log file where there is data in two columns (separated by a space). The file is thus: 0.0 3 0.0 6 0.0 6 0.0 6 0.0 7 0.0 7 0.0 7 0.0 7 0.0 11 0.0 11 0.0 11 0.0 11 0.0 11 0.1 17 (6 Replies)
Discussion started by: Flamex
6 Replies

8. Shell Programming and Scripting

How to eliminate < > sign meaning

Hi I would like to replace one of our script, and add some pre-checking for the input file before running the command, but I bumped into the following issue: Original command: use < input.txt I cannot modify the original command, but I created the useit script which would be called as... (2 Replies)
Discussion started by: apapp
2 Replies

9. Shell Programming and Scripting

Remove unwanted data?

Hi Can any one help me remove the unwanted data? I would want to remove the complete event id 4910 ( the type there is INFO), that means, I have to remove starting from 7th - 19th lines. can any one of you please help? Thanks, (24 Replies)
Discussion started by: hitmansilentass
24 Replies

10. Shell Programming and Scripting

How to eliminate extra char?

I was trying to grep a variable with one space in my file: questionlabel=Q1 more job.tex Q1 pear Q1A applie grep -i "$questionlabel\ " job.tex > tmp But I keep getting : Q1 and Q1A both in my tmp Thanks!!!! (4 Replies)
Discussion started by: whatisthis
4 Replies
Login or Register to Ask a Question