- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find string and replace with variable value
Operating System - HP-UX
1748157
Members
4253
Online
108758
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
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
тАО01-09-2009 02:57 AM
тАО01-09-2009 02:57 AM
find string and replace with variable value
Hi,
I have one file contains headera.
XHEADER 200800901001 REC
as,34,rttt
as,35,rttt
as,36,rttt
FOOTER
___________________________________
Now i have one variable:
count=10
Ihave to replace HEADER 'REC' with 10
then HEADER WILL be
_____________________________
XHEADER 200800901001 10
as,34,rttt
as,35,rttt
as,36,rttt
FOOTER
_______________________________
Can some please help me?
Thanks
I have one file contains headera.
XHEADER 200800901001 REC
as,34,rttt
as,35,rttt
as,36,rttt
FOOTER
___________________________________
Now i have one variable:
count=10
Ihave to replace HEADER 'REC' with 10
then HEADER WILL be
_____________________________
XHEADER 200800901001 10
as,34,rttt
as,35,rttt
as,36,rttt
FOOTER
_______________________________
Can some please help me?
Thanks
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2009 03:43 AM
тАО01-09-2009 03:43 AM
Re: find string and replace with variable value
Use sed:
sed /REC/$count/.. file
not sure of the exact syntax.
sed /REC/$count/.. file
not sure of the exact syntax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2009 04:39 AM
тАО01-09-2009 04:39 AM
Re: find string and replace with variable value
Hi:
You can use:
# sed -e "s/REC/$count/" file > file.new
# mv file.new file
Note the use of the double quotes.
You could also use Perl and update your file, in-place, in one "operation":
# perl -pi -e "s/REC/$count/" file
Regards!
...JRF...
You can use:
# sed -e "s/REC/$count/" file > file.new
# mv file.new file
Note the use of the double quotes.
You could also use Perl and update your file, in-place, in one "operation":
# perl -pi -e "s/REC/$count/" file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2009 07:30 AM
тАО01-09-2009 07:30 AM
Re: find string and replace with variable value
If you only want to change REC in lines that have XHEADER you can change JRF's sed:
sed -e "/XHEADER/s/REC/$count/" file > file.new
sed -e "/XHEADER/s/REC/$count/" file > file.new
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