- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sed usage
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2005 10:55 PM
10-02-2005 10:55 PM
sed usage
I am writing a setup srcipt which want to replace one line of the file /etc/passwd
root::0:3::/:/sbin/sh
daemon:*:1:5::/:/sbin/sh
bin:*:2:2::/usr/bin:/sbin/sh
sys:*:3:3::/:
adm:*:4:4::/var/adm:/sbin/sh
uucp:*:5:3::/var/spool/uucppublic:/usr/lbin/uucp/uucico
lp:*:9:7::/var/spool/lp:/sbin/sh
nuucp:*:11:11::/var/spool/uucppublic:/usr/lbin/uucp/uucico
hpdb:*:27:1:ALLBASE:/:/sbin/sh
nobody:*:-2:-2::/:
www:*:30:1::/:
smbnull:*:101:101:DO NOT USE OR DELETE - needed by Samba:/home/smbnull:/sbin/sh
to root::0:3::/.root:/sbin/ksh, my idea is to use sed
grep root /etc/passwd | sed -e 's/"/"/"/.root"/' -e 's/"/sbin/sh"/"/sbin/ksh"/'
but I find that the character / is the special.
Do anyone has an idea? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2005 10:58 PM
10-02-2005 10:58 PM
Re: sed usage
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2005 11:01 PM
10-02-2005 11:01 PM
Re: sed usage
I would rethink this whole proposal if I were you.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2005 11:04 PM
10-02-2005 11:04 PM
Re: sed usage
If you want to play manually then,
# cp -p /etc/passwd /etc/passwd.bak
# passwd -e /sbin/ksh root
It will change /sbin/sh to /sbin/ksh
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2005 11:06 PM
10-02-2005 11:06 PM
Re: sed usage
# ls /sbin/ksh (11.11 and 11.23)
/sbin/ksh not found
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2005 11:09 PM
10-02-2005 11:09 PM
Re: sed usage
e.g.
# sed -e 's|before|after|g' file
uses the pipe symbol '|' as the delimiter.
so in your case ...
grep "^root:" /etc/passwd | sed -e 's|/sbin/sh|/sbin/ksh|'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2005 11:12 PM
10-02-2005 11:12 PM
Re: sed usage
Pete is correct. Unless you only want to boot your system one last time, do *NOT* change root's shell! It must remain '/sbin/sh' as he noted. On HP-UX, 'sh' is the POSIX shell which is a superset of the Korn88 shell -- which is all you get with '/usr/bin/ksh'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2005 11:13 PM
10-02-2005 11:13 PM
Re: sed usage
# sed -e '/root/s/sh/ksh/g' /etc/passwd
It won't update in /etc/passwd
You can negate / with \ or else s## instead of s// or s%%.
# echo "root::0:3::/.root:/sbin/sh" | sed -e '/root/s%/sbin/sh%/sbin/ksh%'
root::0:3::/.root:/sbin/ksh
# echo "root::0:3::/.root:/sbin/sh" | sed -e '/root/s#/sbin/sh#/sbin/ksh#'
root::0:3::/.root:/sbin/ksh
# echo "root::0:3::/.root:/sbin/sh" | sed -e '/root/s/\/sbin\/sh/\/sbin\/ksh/'
root::0:3::/.root:/sbin/ksh
# echo "root::0:3::/.root:/sbin/sh" | sed -e '/root/s|/sbin/sh|/sbin/ksh|'
root::0:3::/.root:/sbin/ksh
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2005 06:43 AM
10-05-2005 06:43 AM
Re: sed usage
It fails for users that are logged on, but can be scheduled to run offshift.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2005 09:08 AM
10-05-2005 09:08 AM
Re: sed usage
There is no difference between ksh and sh on hpux anymore, so NO reason to make this change anyway.