- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk script for changing a constant string in a...
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
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
09-04-2008 10:28 AM
09-04-2008 10:28 AM
I have one file "test" and another file "range". See below the data. I want to create another file as below called RESULT that the constant data 0000 in first column to be replaced with 0001 for the first row, 0002 for the second row and so on.
test
------------------
'0000', '490685'
'0000', '490686'
'0000', '490687'
.
.
.
range
-------------------
0001
0002
0003
.
.
.
8621
RESULT
---------------------
'0001', '490685'
'0002', '490686'
'0003', '490687'
.
.
.
Thanks,
Andy
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2008 10:32 AM
09-04-2008 10:32 AM
Re: awk script for changing a constant string in all rows with a variable string
# paste -d " " range test |awk '{print $1,$3}' > RESULT
...by the way, file's name simply 'test' are a not-so-good idea.
Regards!
...JRF...
- Tags:
- paste
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2008 10:53 AM
09-04-2008 10:53 AM
Re: awk script for changing a constant string in all rows with a variable string
The result is not the expected:
after your script
------------------
0001 '490685'
0002 '490686'
0003 '490687'
requested
----------------
'0001', '490685'
'0002', '490686'
'0003', '490687'
Thanks,
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2008 11:02 AM
09-04-2008 11:02 AM
Re: awk script for changing a constant string in all rows with a variable string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2008 11:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2008 11:20 AM
09-04-2008 11:20 AM
Re: awk script for changing a constant string in all rows with a variable string
Actually, for your requirement, I find Perl more straightforward:
# paste -d " " ranger tester|perl -nale 'print join ",","\047$F[0]\047",$F[2]'
...where \047 is the octal representation of a single quote.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2008 11:51 AM
09-04-2008 11:51 AM