- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: UNIX 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
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
06-19-2002 11:14 AM
06-19-2002 11:14 AM
UNIX script
I am trying to write a parsing script, how do I remove &_requestid=808, number is different for request ids so 's/&request_id=//' is not going to work.
[05/Jun/2002:04:29:34 /index2.jhtml/myhome/index.jhtml&_requestid=808 "-"
[05/Jun/2002:04:49:41 /index2.jhtml/myhome/index.jhtml&_requestid=1048 "-"
[05/Jun/2002:07:14:38 /index2.jhtml/myhome/index.jhtml&_requestid=1676 "-"
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2002 11:17 AM
06-19-2002 11:17 AM
Re: UNIX script
sed -e 's/&_requestid=.*//'
This will remove everything past &_requestid
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2002 11:19 AM
06-19-2002 11:19 AM
Re: UNIX script
The regular expression "[0-9][0-9][0-9]" should match any string of three consecutive digits.
I'm not sure how well this will display, but there are no spaces between the double quotes. And the quotes would not be included in your search string.
And you'll probably have to escape the & with a backslash:
's/\&request_id=[0-9][0-9][0-9//'
HTH,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2002 11:19 AM
06-19-2002 11:19 AM
Re: UNIX script
You could use something like:
sed -e 's/&request_id=[[:digit:]]*//'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2002 11:33 AM
06-19-2002 11:33 AM
Re: UNIX script
Thanks for the responses, but none of them are working.
This one will remove requestid and the other columns after that, I want to keep other columns
sed -e 's/&_requestid=.*//'
Something like these commands should work but they are not working.
's/\&request_id=[0-9][0-9][0-9//'
sed -e 's/&request_id=[[:digit:]]*//'
Any help is appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2002 11:54 AM
06-19-2002 11:54 AM
Re: UNIX script
It looks like I had miss copied your test string. You had "_requestid" and I had copied it as "request_id". So now that I'm past that, here's what I did ( on a 10.20 system ):
I created a file called parsing.sed:
s/&_requestid=[[:digit:]]*//g
Then I executed sed with:
sed -f parsing.sed myfile > newfile
"myfile" was a cut and past of your test data above. Note that I've incorporated James' suggestion of using [[:digit:]]*. My first response would not have worked with numerical strings longer than three digits. I hadn't noticed that you had examples with more than three digits.
This worked okay for me with your test data. My "newfile" looks like this:
[05/Jun/2002:04:29:34 /index2.jhtml/myhome/index.jhtml "-"
[05/Jun/2002:04:49:41 /index2.jhtml/myhome/index.jhtml "-"
[05/Jun/2002:07:14:38 /index2.jhtml/myhome/index.jhtml "-"
HTH,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2002 12:01 PM
06-19-2002 12:01 PM
Re: UNIX script
I, too used the example of "request_id" and not your "requestid" string! Is that what you missed? Thy this:
# echo "my&requestid=808alpha\nyour&requestid=909beta"||sed -e 's/request_id=[[:digit:]]*//'
For output, you ahould have:
myα
yourβ
In the form using [0-9], you are missing a closing bracket "]" for the last part of the expression.
Regards!
...JRF...