- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script help
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-27-2004 11:14 PM
07-27-2004 11:14 PM
07/22/2004 11:07:59,LUN 150 [150; RAID 5; hkhpdv11.oocl.com],0.0,0.0,0.0,0.0,0.0
,0.0,0.0
07/22/2004 11:12:59,LUN 150 [150; RAID 5; hkhpdv11.oocl.com],0.0,0.0,0.0,0.0,0.0
,0.0,0.0
which each , represent a field, how can I global delete those .0* field, i.e change all field value to integer? thx.
Gordon
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2004 11:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2004 11:29 PM
07-27-2004 11:29 PM
Re: Script help
cat file|awk -F "]" '{print $1}'
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2004 11:48 PM
07-27-2004 11:48 PM
Re: Script help
Check the files for .0 with grep as,
while read line; do
grep -v "\.0" $line
if [[ $? -eq 0 ]]; then
echo $line | awk -F "," '{
print $1 $2
for (i=3;i
}'
fi
done <
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 01:51 AM
07-28-2004 01:51 AM
Re: Script help
perl -p -i -e 's/(\d+)\.\d+/\1/g' yourfile.txt
This will apply the changes directly to "yourfile.txt". If you rather generate a new file with the results-
perl -p -e 's/(\d+)\.\d+/\1/g' yourfile.txt >new_yourfile.txt
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 01:29 PM
07-28-2004 01:29 PM
Re: Script help
thx all for yr help, I find the perl solution do what exactly I want!! thx all again !
Gordon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 01:30 PM
07-28-2004 01:30 PM
Re: Script help
thx all for yr help, I find the perl solution do what exactly I want!! However, there is still problem that I donno, my input has some line that has "E" extentsion for number. e.g.
07/22/2004 11:52:59 0.0 0.0 4.834483779821818E-6 0.00330034092702
50276 0.0 0.5 0.0 150
Using the perl script, it give out E-6 as output but not '4', any idea? thx.
Gordon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 02:53 PM
07-28-2004 02:53 PM
Re: Script help
If you want the script to magically match up more number formats then you'll have to teeach it that through a more complex regular expression. In your case it looks like you are only interested in negative Exponentials (E-). You can express that with:
perl -p -e 's/(\d+)\.\d+(E-\d+)?/\1/g' infile > outfile.
What I added to the prio solution was:
(E-\d+)?
That means:
- a group: ()
- of E followed by - followed by one or more digits: E-\d+
- and that group must me present 0 or 1 times to match: ?
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 03:41 PM
07-28-2004 03:41 PM
Re: Script help
Great, this fix the issue, yes I am a newbie for Perl, do donno the syntax of Perl, can u share with me some good source to learn Perl, esp for above line it's a very useful perl one-liner that I must use frequently, but since I donno the syntax, so donno how to modify the "rule"....
thx again.
Gordon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 03:59 PM
07-28-2004 03:59 PM
Re: Script help
I'd recommend the 'camel' books. O'reilly.
Check out: http://learn.perl.org/
and: www.perldoc.com
cheers,
Hein. [0 points for this]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 04:07 PM
07-28-2004 04:07 PM
Re: Script help
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=646837
Check out the 'regular expression' suggestion. Because more then Perl, that's what you need to learn for tasks you describe.
Cheers,
Hein.
extracts:
Fred Ruffet Jul 28, 2004 12:02:11 GMT
-------------------------------------------
Let me tell you I consider the camel book (O'Reilly Perl Reference) as the better book on the subject. Notice that for learning there is also the good Lama Book (O'Reilly Learning Perl). The last editions are are up2date.
procura Jul 28, 2004 13:01:01 GMT
-------------------------------------------
Even knowing that I am a *real* Perl fanatic, the best book for regular expressions is Jeffrey Friedl's "Mastering Regular Expressions" from O'Reilly
An absolute must for anyone using vi, perl, awk, grep, sh, sed, emacs, ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 06:20 PM
07-28-2004 06:20 PM
Re: Script help
Sorry , but I cannot find the "camel books", can u pls enlighen, many thx thx.
Gordon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 06:36 PM
07-28-2004 06:36 PM
Re: Script help
Start here: http://www.oreilly.com/catalog/prdindex.html
browse don to the books starting with "Perl" and find
http://www.oreilly.com/catalog/pperl3 (the bible. the only true reference, except for the on-line docs of course)
http://www.oreilly.com/catalog/lperl3 (the beginner book. Read once and pass on)
http://www.oreilly.com/catalog/perlpr4 (an absolute need. I still use it daily)
http://www.oreilly.com/catalog/perlckbk2 (the Ram book, a good addition)
Also visit my site to read:
--8<---
For those that are not (yet) comfortable with Perl, [0]Wendy van Dijk has put up a nice article on [1]use.perl.org titled "Where and how to start learning Perl".
-->8---
[0] http://perlmonks.org/index.pl?node_id=283154
[1] http://use.perl.org/
[2] http://perlmonks.org/index.pl?node_id=284175
My HP ITRC site pages can be found at (please use LA as primary choice):
USA Los Angeles http://mirrors.develooper.com/hpux/
SGP Singapore https://www.beepz.com/personal/merijn/
USA Chicago http://ww.hpux.ws/merijn/
NL Hoofddorp http://www.cmve.net/~merijn/
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 06:39 PM
07-28-2004 06:39 PM
Re: Script help
http://www.oreilly.com/catalog/regex2 (Mastering Regular Expressions)
Don't buy the first edition. It's very outdated now 2nd ed is out!
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 09:40 PM
07-28-2004 09:40 PM
Re: Script help
Gordon