- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Using VI to insert line from bash script
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
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
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-21-2008 03:44 AM
тАО10-21-2008 03:44 AM
Solution>> So, how can I do this with awk ?
yes, but WHY?
awk '/^17,10:1/ {gsub (/,/, ",9.5/E\n,")} {print} ' x
>> It's work, Any more powerful Ideas ?
Only if you describe in a powerful way where the 17 and the 9.1 (9.5) and such come from.
Are they really just fixed strings, always the same? That is a totally boring case. Just pick a solution and be happy.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2008 04:06 AM
тАО10-21-2008 04:06 AM
Re: Using VI to insert line from bash script
My customer changed his idea so I had to change my work. And yes, it's easy one.
But in your awk command, you didn't insert ",10:1" value.
Last thing before I close this case, do you recommend a useful awk and sed from personal experiences?
Thanks :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2008 04:32 AM
тАО10-21-2008 04:32 AM
Re: Using VI to insert line from bash script
It seems your line working great. although, I didn't notice that you wrote ",10:1" in your line. But your awk line doing what I want do do. It's amazing :)
I want to learn how to use awk because this line is more powerful than complex bash script.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2008 04:38 AM
тАО10-21-2008 04:38 AM
Re: Using VI to insert line from bash script
If you want to start with 'awk' you could use this free, but excellent guide:
http://www.gnu.org/software/gawk/manual/gawk.html
Be aware that the GNU variant is a bit more powerful than HP's or AIX's standard.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2008 04:50 AM
тАО10-21-2008 04:50 AM
Re: Using VI to insert line from bash script
Thanks folks for your support.
Have a nice day.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2008 04:52 AM
тАО10-21-2008 04:52 AM
Re: Using VI to insert line from bash script
It's awk command. It's powerful.
awk '/^17,10:1$/ { gsub (/,/, ",9:5/E\n,") } { print }'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2008 05:44 AM
тАО10-21-2008 05:44 AM
Re: Using VI to insert line from bash script
I did't write ,10:1. That was already there :-).
I just stuck a new-line ( \n ) in front of it.
I wrote my solution in anticipation of future, other needs. That's was seperates solutions from hacks.
My assumption was that you did not want "10:1" but "whatever was on the old line after the comma"... which happens to be 10:1 for now.
Similar for the 17. I left the value itself on the line, using it only as a simple regular expression untill you explained better where the 17 came from.
I only replaced the comma, not the values.
Try this:
$ awk '/^[0-9]+,/ {gsub (/,/, ",9.5/E\n,")} {print} ' x
... no 17, no 10, and yet...
>> I want to learn how to use awk because this line is more powerful than complex bash script.
I was hoping that, and that's why I providede the blow-by-blow breakdown in my first example. Try to follow that!
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2008 03:31 PM
тАО10-21-2008 03:31 PM
Re: Using VI to insert line from bash script
Your example above would be:
ex a << EOF
i
insert data
.
wq
EOF
- Tags:
- ex
- « Previous
-
- 1
- 2
- Next »