Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

more file

param1=" 1,deerfntjefnerjfntrjgntrjnvgrvgrtbvggfrjbntr*rfr4fv*frfftrjgtrignmtignmtyightygjn 2,3,4,5,6,7,8,

need to match the content of $param1 in the file but its not work for example sed -n "/$param1/p" file
or any grep $param1 file etc...

any other solutions? maybe with perl?

share|improve this question
Please post the complete, exact script or command line you are using, along with the exact input & output, and explain what you expected. Then we can probably help. – sleske May 31 '10 at 14:20
for example grep -w $param1 file when file content: 1,deerfntjefnerjfntrjgntrjnvgrvgrtbvggfrjbntrrfr4fvfrfftrjgtrignmtignmtyightyg‌​jn 2,3,4,5,6,7,8, rfcmckmfdkckemdio8u548384omxc,mor0ckofcmineucfhcbdjcnedjcnywedpeodl40fcrcmkedmri‌​kmckffmcrffmrfrifmtrifmrifvysdfn _______and param1 is: param1=" 1,deerfntjefnerjfntrjgntrjnvgrvgrtbvggfrjbntrrfr4fvfrfftrjgtrignmtignmtyightyg‌​jn 2,3,4,5,6,7,8, rfcmckmfdkckemdio8u548384omxc,mor0ckofcmineucfhcbdjcnedjcnywedpeodl40fcrcmkedmri‌​kmckffmcrffmrfrifmtrifmrifvysdfn" – yael May 31 '10 at 14:22
@yael:Please edit your answer, rather than posting a comment. That's what the "edit" button under the answer is for :-). – sleske May 31 '10 at 14:27

Hard to help without the exact script you are running, but one point to check:

The value for "param1" that you posted contains asterisk characters ("*"). These have special meaning to sed and grep (and perl, and generally in any regular expression). To match these as literal characters, you usually need to "escape" them by prepending a backslash.

So instead of "aa*b" you'd need "aa*b". Try this first to see if it helps.

Caveat: The shell will also process a \, so when using it as a parameter value put the value into '', as:


The '' will protect special chars from the shell.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.