1

This is my command:

echo "Test" | sed -f <(sed -e 's/.*/s,&,gI/' mydic)  

The file mydic contains 2 columns delimited by commas (,)

a,AlphabetA  
.  
.   
.    
e,AlphabetE   
.   
.   
s,AlphabetS  
.   
t,AlphabetT   
test,testedd   
.   
.   
zebra,zebraaaa

The expect result is testedd, but I get AlphabetTAlphabetEAlphabetSAlphabetT.

2 Answers 2

2
echo Test |sed -f <(sed 's/\(.*\),\(.*\)/s,\\<\1\\>,\2,gI/' mydic)

\< and \> indicate the start and end of a word, respectively.

0
1

You've asked it to replace "e" with "AlphabetE", which it's done correctly. I suspect you meant it to only consider whole words?

Try this:

echo "test" | sed -f <(sed -e 's/.*/s,\\<&\\>,gI/' mydic)

Edit: I noticed you had in fact dealt with the case issue.

2
  • Yes I meant the whole word and your command result is sed only the first alphabet. Result: AlphabetT>est
    – Runicer
    Apr 10, 2012 at 16:01
  • Ah, I see what I did wrong. Yes, @Peter has made the right adjustment.
    – ams
    Apr 10, 2012 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .