- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: trouble with sed
Operating System - HP-UX
1753784
Members
6712
Online
108799
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО08-24-2009 04:20 PM
тАО08-24-2009 04:20 PM
Hello, I have a text file named c01362 that contains the following information:
c01362:u_name=c01362:u_id#7043:\
:u_pwd=*:\
:u_auditid#21:\
:u_auditflag#1:\
:u_pswduser=c01362:u_suclog#1251142126:u_suctty=pts/tk:u_unsuclog#1239205577:\
:u_unsuctty=pts/tc:u_lock@:chkent:
I'm trying to use sed to replace the ":u_pwd=*:\" line with ":u_pwd=$tom:\" where $tom is a variable assigned the value 8675309.
The best I can get is this ":u_pwd=8675309*:\".
For some reason I can't get rid of the "*" character.
Here's the sed command I'm using
cat c01362 | sed -e "s~:u_pwd=*~:u_pwd=$tom~g"
When I try including the ":\" in the sed command (both with and without an escape character) I receive a "cannot be parsed" error as shown below.
cat c01362 | sed -e "s~:u_pwd=*:\\~:u_pwd=$tom:\\~g"
sed: Function s~:u_pwd=*:\~:u_pwd=8675309:\~g cannot be parsed.
cat c01362 | sed -e "s~:u_pwd=*:\~:u_pwd=$tom:\~g"
sed: Function s~:u_pwd=*:\~:u_pwd=8675309:\~g cannot be parsed.
Can anyone suggest how to replace the ":u_pwd=*:\" line within the text file I listed above with ":u_pwd=$tom:\"?
I'd really appreciate any assistance.
Thank you.
Tom
c01362:u_name=c01362:u_id#7043:\
:u_pwd=*:\
:u_auditid#21:\
:u_auditflag#1:\
:u_pswduser=c01362:u_suclog#1251142126:u_suctty=pts/tk:u_unsuclog#1239205577:\
:u_unsuctty=pts/tc:u_lock@:chkent:
I'm trying to use sed to replace the ":u_pwd=*:\" line with ":u_pwd=$tom:\" where $tom is a variable assigned the value 8675309.
The best I can get is this ":u_pwd=8675309*:\".
For some reason I can't get rid of the "*" character.
Here's the sed command I'm using
cat c01362 | sed -e "s~:u_pwd=*~:u_pwd=$tom~g"
When I try including the ":\" in the sed command (both with and without an escape character) I receive a "cannot be parsed" error as shown below.
cat c01362 | sed -e "s~:u_pwd=*:\\~:u_pwd=$tom:\\~g"
sed: Function s~:u_pwd=*:\~:u_pwd=8675309:\~g cannot be parsed.
cat c01362 | sed -e "s~:u_pwd=*:\~:u_pwd=$tom:\~g"
sed: Function s~:u_pwd=*:\~:u_pwd=8675309:\~g cannot be parsed.
Can anyone suggest how to replace the ":u_pwd=*:\" line within the text file I listed above with ":u_pwd=$tom:\"?
I'd really appreciate any assistance.
Thank you.
Tom
Solved! Go to Solution.
- Tags:
- sed
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2009 04:44 PM
тАО08-24-2009 04:44 PM
Solution
Hi Tom:
# tom=8675309
# sed -e "s~:u_pwd=\*~:u_pwd=$tom~g" c01362
That is, escape the * metacharacter.
Also, 'sed' reads its input from the command line. You don't need the extraneous 'cat' with a pipe. I love cats, but they have their place :-)
Regards!
...JRF...
# tom=8675309
# sed -e "s~:u_pwd=\*~:u_pwd=$tom~g" c01362
That is, escape the * metacharacter.
Also, 'sed' reads its input from the command line. You don't need the extraneous 'cat' with a pipe. I love cats, but they have their place :-)
Regards!
...JRF...
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2009 06:55 AM
тАО08-25-2009 06:55 AM
Re: trouble with sed
Hello James, that worked perfectly.
I overlooked the obvious.
Thanks for the help.
I overlooked the obvious.
Thanks for the help.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP