- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sed Issue .. (delimiter)
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
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
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
09-14-2012 08:40 AM
09-14-2012 08:40 AM
I everyone I need some help with a sed statement.
This is a scirpt that updates the /etc/shadow on linux and solaris.
And I am having probems with one line.
ssh -q ${HOST} 2>/dev/null "rm /tmp/shadow.*"
ssh -q ${HOST} 2>/dev/null "cp /etc/shadow /tmp/shadow.bak"
ssh -q ${HOST} 2>/dev/null "sed -e '/^root:/s/:[^:]*:/:${PASS}:/' /tmp/shadow.bak > /tmp/shadow.new"
Most of the time it works without any issues but for some reason everyone once in a while /tmp/shadow.new is empty. The file is there .. just nothing in it.
-rw------- 1 root root 0 Sep 14 10:32 /tmp/shadow.new
Is there something wrong with my sed staement?
Or am I missing something?
Thanks
Ricardo
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2012 11:25 AM
09-14-2012 11:25 AM
Re: Sed Issue ..
Im a little closer ..
it seems that the issue happens when the password hash has a \ or / in it.
I get the following errors:
sed: command garbled:
or
sed: -e expression #1, char 29: Unknown option to `s'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2012 12:00 PM - edited 09-14-2012 01:10 PM
09-14-2012 12:00 PM - edited 09-14-2012 01:10 PM
Re: sed Issue .. (delimiter)
>it seems that the issue happens when the password hash has a \ or / in it
You could replace that sed "/" by a comma.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2012 12:26 PM
09-14-2012 12:26 PM
Re: Sed Issue ..
Hi Dennis
Can you clarify ..
If the password hash is
abcdef123/ABC
And I change it to
abcdef123,ABC
That makes the password different and doesnt work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2012 01:09 PM - edited 09-14-2012 01:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2012 01:21 PM
09-14-2012 01:21 PM
Re: sed Issue .. (delimiter)
Thanks !!!
That worked like a charm !!
Woud you mind explaining what the comma does?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2012 06:44 PM
09-14-2012 06:44 PM
Re: sed Issue .. (delimiter)
>Would you mind explaining what the comma does?
The same as the "/". :-)
You can use any char as the delimiter, as long as it matches. From sed(1):
(2)s/regular expression/replacement/flags
Substitute replacement string for instances of regular
expression in the pattern space. Any character can be
used instead of /. For a fuller description see ed(1).
It seems you can even use a ";", though it is normally a command separator.