Partial Match and Replace

Hi, I have a tab delimited text file like this one. I need to do a partial match of a particular cell and then replace matches with an empty cell. So here is a sample:

Smith	FordMustang	ChevroletCamaro
Miller	FordFiesta
Jones	KiaSorrento
Davis	ChevroletCamaro
Johnson	ToyotaHighlander

I need to do a partial match within "makemodel" and replace with noting. For example search "Ford" and replace these partial matching cells with nothing

Smith		ChevroletCamaro
Miller	
Jones	KiaSorrento
Davis	ChevroletCamaro
Johnson	ToyotaHighlander

as a start....

MATCH=Ford
sed -r -e "s/$MATCH[^[:space:]]+//g" file.txt

This works. But on my real dataset, I still have a problem.

The problem is that I need

sed -E -e "s/ord[^[:space:]]+//g" file.txt

With "ord" to work, too. So it needs to be "wild carded" at the beginning of the word to work, too.

In my "real" dataset, my column has something more like this to be flagged whenever there is Ford

1998 Ford Mustang
1996 Ford Festiva

---------- Post updated at 07:19 PM ---------- Previous update was at 07:15 PM ----------

And when I use this

sed -E -e "s/.*ord[^[:space:]]+//g" file.txt

It deletes EVERYTHING before Ford . I only need that particular column cell replaced.

Hi,

you can try the following:

sed -e 's/ Ford[a-zA-z]+//g' file

g is added for global replacement for given input in post #1 g is not required.

or

awk '{for (i=1;i<=NF;i++) { if ($i ~ /Ford/) $i =x; } }1' file 

If it does not help, please post your input and desired output.

Try:

del=Ford; sed "s/[^[:blank:]]*${del}[^[:blank:]]*//g" infile

or

awk -v del="Ford" '{for (i=1;i<=NF;i++) if($i~del) $i=x}1' FS='\t' OFS='\t' infile