- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting
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
09-26-2002 04:50 PM
09-26-2002 04:50 PM
I would like to reformat a file by removing all the ,*, fields from the attached txt file. Your scripting knowledge would be muchly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 04:57 PM
09-26-2002 04:57 PM
Re: Scripting
221 to Q0
**I to O6 (where * wild)
***R to O4 (where * wild)
***G to P1 (where * wild)
Many thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 05:02 PM
09-26-2002 05:02 PM
Re: Scripting
This will remove all occurances of the string comma_asterisk_comma:
# sed -e 's/,\*,//g' filename
Is that what you want?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 05:08 PM
09-26-2002 05:08 PM
Re: Scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 05:08 PM
09-26-2002 05:08 PM
Re: Scripting
# sed -e 's/,\*,/|/g' filename
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 05:39 PM
09-26-2002 05:39 PM
Re: Scripting
Thankyou very much for your help.
Thats getting near to what I need, all I need now is changing the following fields
22I to Q0 (field 2)
**I to O6 (field 2 where * is wild)
***R to O4 (field 6 where * is wild)
***G to P1 (filed 9 where * is wild)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 06:45 PM
09-26-2002 06:45 PM
SolutionOK. We'll use 'sed' to translate the ,*, strings to a pipe as already done. At this point is appears that you want to make translations on field number 2, 6, and 9 if I understand correctly.
Hence, pipe the output of the 'sed' to an 'awk' script. Essentially, we will need to examine fields 2, 6, and 9 for anyone of the conditions you cited and substitute.
Using one of the lines in your file:
IIF ,*,22I,*,2,*, ,*,OS,*,036R,*, ,*, ,*,068G,*, ,*,
...THEN: sed -e 's/,\*,/|/g'
...produces:
IIF |22I|2| |OS|036R| | |068G| |
...which we pipe to an 'awk' script, the beginnings of which might look like:
awk -F\| 'BEGIN{OFS="|"}; $2~/..I/ {$2="xxx"};$6~/...R/ {$6="yyy"};{print $0}'
...which with the above data would yield:
IIF |xxx|2| |OS|yyy| | |068G| |
...I've used "xxx" and "yyy" for clarity of substitution. For brevity, I didn't write a complete 'awk' script, only enough to show conceptually my suggestion.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 08:54 PM
09-26-2002 08:54 PM
Re: Scripting
How can I thankyou, If you were in Australia I would buy you a beer.