Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with sed one liner

Status
Not open for further replies.

jouell

MIS
Nov 19, 2002
304
US
Hi

How can I make sed happy with this command:

sed -i -e #"${ID_IN_PASSWORD_QUEUE}${DELIM1}${PASSWORD_IN_PASSWORD_QUEUE}"#d



I can replace the text with blanks first instead (with s###g) and then remove the blanks with:

sed -i -e /'^ *$'/d $1


But I keep getting error when I try to do it in one step.

sed: option requires an argument -- e

I know my quotes must be wrong....

Can anyone lend a pair of eyes?



 
Hi

The slash delimite could be replaced with something else only in the [tt]s///[/tt] command, not in the pattern.

And is not clear where is the file name in your first command.

Eventually you can show some possible values of your variables too.

Feherke.
 
The [tt]#[/tt] is a comment character. Your command line basically ends with that first [tt]#[/tt].

I'm not really clear on the pattern you're trying to match on. It would help if you can clarify that.

Try this...
Code:
sed -i -e "#${ID_IN_PASSWORD_QUEUE}${DELIM1}${PASSWORD_IN_PASSWORD_QUEUE}#d"
Put your edit commands in either single or double quotes and you should be ok.

Hope this helps.
 
Thanks for the respsonses.

I don't know what the pattern is. It is a user defined field. An example , however would be:

3+12346+/bin/cat /etc/passwd | sort

But it would be passed in via the variables above, where DELIM1 is the "+" sign.


hence I know I will be dealing with "/" characters much more than (if at all) the "#".

Does this make sense?

Thanks for all the input!
 
Well I gave up on my crazy method.
I think it was needlessly complex.

Instead, I am removing a line based on the unique ID number it starts with:

sed -i -e /"^$ID_IN_PASSWORD_QUEUE"/d $1

and this much more stable for my script.

I guess sometimes simple is better!

Thanks for all the help!

-John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top