Problem with sed - It misinterprets | (pipe).
From: LOEWENTHAL Simon (sloewenthal_at_gemini.edu)
Date: 05/31/05
- Previous message: Daryl.Mitchell_at_us.o-i.com: "SUMMARY: to mirror swap or not to mirror swap, that is the question"
- Next in thread: LOEWENTHAL Simon: "SUMMARY: Problem with sed - It misinterprets | (pipe)."
- Reply: LOEWENTHAL Simon: "SUMMARY: Problem with sed - It misinterprets | (pipe)."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 May 2005 11:14:57 -0400 To: Sun Mangers <sunmanagers@sunmanagers.org>
Dear all Sed madmen,
I'm trying to write something that sets the encrypted field in the
shadow file to *LK*, but sed will choke whenever the field has a / in
it, so I wrote something to nest sed inside sed with cut so that it
replaces instances of / with /\
However, sed chokes when interpreting the |. I have tried putting ' and
` in all the places I can think of, but it usually makes it worse.
Cut the encrypted password out and then get gsed to replace the / with
\, which work fine.
Cat shadow.t
GogunE:ndY3rmE/bkxt.:12180::::::
echo `cut -d: -f2 shadow.t`|gsed -s 's/\//\\\//g'
What it correctly produces,
ndY3rmE\/bkxt.
Finally I use gsed to replace the earlier output with *LK*.
gsed -e 's/'`echo `cut -d: -f2 shadow.t`|gsed -s
's/\//\\\//g'`'/\*LK\*/' <shadow.t
Then it chokes,
./test: syntax error at line 1: `|' unexpected
Regards, S.
PS. I'm sorry that this is not Sun specific, but I think that there are
plenty of sed users in the audience, but I've been at this for the past
5 hours and am starting to doubt my sanity.
-- ISG/Gemini/AURA _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagers
- Previous message: Daryl.Mitchell_at_us.o-i.com: "SUMMARY: to mirror swap or not to mirror swap, that is the question"
- Next in thread: LOEWENTHAL Simon: "SUMMARY: Problem with sed - It misinterprets | (pipe)."
- Reply: LOEWENTHAL Simon: "SUMMARY: Problem with sed - It misinterprets | (pipe)."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]