- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How do I write this scipt
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
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
07-14-2003 11:52 AM
07-14-2003 11:52 AM
How do I write this scipt
fruit="apple pear banana"
I want to modiy it to something like
fruit="apple cherry pear banana strawberry"
How do I write this shell command? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2003 11:56 AM
07-14-2003 11:56 AM
Re: How do I write this scipt
fruit="apple pear bannana"
var2="stawberry"
fruit="${fruit}${var2}"
echo $fruit
Output is:
apple cherry pear banana strawberry
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2003 12:01 PM
07-14-2003 12:01 PM
Re: How do I write this scipt
YOu will need to where you are going to add your values. To add cherry after apple and strawberry to the end, I would do the following
fruit=$(echo $fruit|sed -e 's/apple/apple cherry/g' -e 's/$/ strawberry/')
There is a space after strawberry in the second sed statement.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2003 01:51 PM
07-14-2003 01:51 PM
Re: How do I write this scipt
fruit="apple pear banana"
fruit="$fruit cherry strawberry"
#echo $fruit
apple pear banana cherry strawberry
You could use awk to add cherry to the middle of the other fruits and strawbwerry to the end:
fruit=`echo $fruit | awk '{print $1_"_cherry_"_$2_"_"_$3_"_strawberry"}'
- replace the underscores with spaces.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2003 05:11 PM
07-14-2003 05:11 PM
Re: How do I write this scipt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2003 12:15 AM
07-15-2003 12:15 AM
Re: How do I write this scipt
fruit="apple pear banana"
fruit="apple cherry pear banana strawberry"
.. unless you are trying to perform an operation on the original value, but you don't give enough information on what you are really trying to do.
:->