HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- shell scripts
Operating System - HP-UX
1830238
Members
3485
Online
109999
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
11-28-2002 07:57 AM
11-28-2002 07:57 AM
i'm a beginner for sed n awk,so i can't reali understand what those means:
sed 's/'"$1"'/&/g
2,$ d' |
awk ' {
right += length($0);
print right, $0;
}'
help from anyone is highly appreciated...
thank you...
sed 's/'"$1"'/&/g
2,$ d' |
awk ' {
right += length($0);
print right, $0;
}'
help from anyone is highly appreciated...
thank you...
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2002 08:01 AM
11-28-2002 08:01 AM
Re: shell scripts
Where did you get the code? Do you have any idea what the input is?
It's usually necessary to see the entire picture, not just what's in the box.
live free or die
harry
It's usually necessary to see the entire picture, not just what's in the box.
live free or die
harry
Live Free or Die
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2002 08:19 AM
11-28-2002 08:19 AM
Solution
hi,
I try to work without context ...
I can't understand the meaning of first sed line, because basically it's supposed to substitute something by ... the same thing ! The & char is usually used with something else, for example :
sed 's/xxx/< & >/g'
would have changed all occurences of xxx in < xxx > (multiple changes on same lines by adding a final g, else sed go to next line after first replacement.
So, first instruction doesn't seem very useful, try with or without it, it's the same ...
then '2,$ d' would suppress all lines after line 1, so 'line' or 'head -1' would have done it quicker.
then right += length($0); would add length of input record to variable 'right', but in your case, with 1 record only, '=' would have been enough ...
And it finally prints the lenght of the record and the record itself.
If you cat a file into this script, same result would be obtained by :
VAR=$(line)
echo ${#VAR} $VAR
Regards
I try to work without context ...
I can't understand the meaning of first sed line, because basically it's supposed to substitute something by ... the same thing ! The & char is usually used with something else, for example :
sed 's/xxx/< & >/g'
would have changed all occurences of xxx in < xxx > (multiple changes on same lines by adding a final g, else sed go to next line after first replacement.
So, first instruction doesn't seem very useful, try with or without it, it's the same ...
then '2,$ d' would suppress all lines after line 1, so 'line' or 'head -1' would have done it quicker.
then right += length($0); would add length of input record to variable 'right', but in your case, with 1 record only, '=' would have been enough ...
And it finally prints the lenght of the record and the record itself.
If you cat a file into this script, same result would be obtained by :
VAR=$(line)
echo ${#VAR} $VAR
Regards
It works for me (© Bill McNAMARA ...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2002 08:52 PM
11-28-2002 08:52 PM
Re: shell scripts
hi harry,
i get this code from the net when i'm searching for some notes on sed codes. i can't understand so i post it up.
anyway thanks for your help.
i really have no idea about this code...
i get this code from the net when i'm searching for some notes on sed codes. i can't understand so i post it up.
anyway thanks for your help.
i really have no idea about this code...
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