HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Scripting
Operating System - HP-UX
1831355
Members
3196
Online
110024
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
Forums
Discussions
Discussions
Discussions
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
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
02-21-2002 03:15 PM
02-21-2002 03:15 PM
Hello,
Can someone please explain to me what the hell does this mean. Your help wil be greatly appreciated.
echo $(echo $LINE\~|sed -e s%^%$i~%)\\c
Can someone please explain to me what the hell does this mean. Your help wil be greatly appreciated.
echo $(echo $LINE\~|sed -e s%^%$i~%)\\c
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 03:30 PM
02-21-2002 03:30 PM
Solution
>>echo $(echo $LINE\~|sed -e s%^%$i~%)\\c <<
The first "echo" is going to display the results of what happens in the parenthesis and suppress the carriabe return that normally would happen at the end of that display.
The second "echo" will display (send to standard out, but you won't see it because the pipe "|" will capture it) the contents of the variable LINE plus a ~ appended to the end. The "\" is there to tell the shell to treat the ~ as just another text character.
The "sed" command is going to read the contents of the pipe (which is the results of the second echo) and substitute all occurances of ^ with the content of the variable "i" plus a ~. The "-e" tells sed what comes next is an editing command; the "%" are delimiters for the editing command.
So the net affect is whatever the variable LINE equals before doing the above will be displayed with all carats being swapped for whatever is in variable i plus a tilde, plus a tilde at the end.
Given:
LINE=1^2^3
i=-
the results would be:
1-~2-~3~
HTH
mark
The first "echo" is going to display the results of what happens in the parenthesis and suppress the carriabe return that normally would happen at the end of that display.
The second "echo" will display (send to standard out, but you won't see it because the pipe "|" will capture it) the contents of the variable LINE plus a ~ appended to the end. The "\" is there to tell the shell to treat the ~ as just another text character.
The "sed" command is going to read the contents of the pipe (which is the results of the second echo) and substitute all occurances of ^ with the content of the variable "i" plus a ~. The "-e" tells sed what comes next is an editing command; the "%" are delimiters for the editing command.
So the net affect is whatever the variable LINE equals before doing the above will be displayed with all carats being swapped for whatever is in variable i plus a tilde, plus a tilde at the end.
Given:
LINE=1^2^3
i=-
the results would be:
1-~2-~3~
HTH
mark
the future will be a lot like now, only later
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 03:45 PM
02-21-2002 03:45 PM
Re: Shell Scripting
Thank you very much for you help Mark but what does the % sign actully mean. What is that there for??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 03:49 PM
02-21-2002 03:49 PM
Re: Shell Scripting
the % is a delimiter, a seperator for the sed command and is a required part of the syntax. Ususally a slash (/) is used, but if either the string being replaced, or the replacement string contain a slash, you have to used something else. Almost anything will do except a backslash, asterisk, and maybe a few other special characters.
I must admit this is the first time I've seen a percent sign used, the usual fallback is a dash or a plus from what I've seen. Of course, either the incoming string from LINE or the contents of variable "i" could have anynumber of different characters in them.
HTH
mark
I must admit this is the first time I've seen a percent sign used, the usual fallback is a dash or a plus from what I've seen. Of course, either the incoming string from LINE or the contents of variable "i" could have anynumber of different characters in them.
HTH
mark
the future will be a lot like now, only later
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.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP