assistance requested (sed related)

I gotta write a command to change the accounts in /etc/passwd that use a shell other than the bash to bash shell. those accounts that dont use a shell shouldnt get modified. assuming all the shell programs end in sh and other programs dont. and the result should go into /etc/passwd.rev

any hint?

Awk is a much less unsuitable tool for manipulating a paswd file than sed.

Also be aware that on many systems root's password is set to /sbin/sh and uses a statically compiles shell which should not be changed.

sed 's#:[^:][^:]*$#/bin/bash#' /etc/passwd

Reborg,

You forget to place a colon before "/bin/bash" and it changes all lines and that's not what the OP wants.
A little fit of your the line:

sed '/.*sh$/s#:[^:][^:]*$#:/bin/bash#' /etc/passwd

A solution with awk should looks like:

awk 'BEGIN{FS=OFS=":"}$7 ~ /.*sh$/{$7="/bin/bash"}1' /etc/passwd

Regards

tnx a lot,
now what if I want to limit my sed further more so that it only looks for the lines that have 144 or 275 somewhere in them?
this is what I have:
sed '/.*144.*sh$/s#:[^:][^:]$#:/bin/bash#' /etc/passwd
how can I include both 144 and 275 before the ".
"?
tnx again

This post looks very similiar to this one - http://www.unix.com/unix-dummies-questions-answers/52123-searching-two-more-patterns-line.html\#post302164089

metalwarrior, you are consistently breaking the rules by double-posting. Please refrain from doing so.