- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Perl scriptin 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
Discussions
Discussions
Forums
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
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
тАО10-26-2005 07:06 PM
тАО10-26-2005 07:06 PM
Perl scriptin help
I am beginner in Perl Scripting. Looking for help.
I want search for the ERROR message in a log file based on Keyword and detected line message text needs to be truncated to 90 characters.
Thanks in advance.
Regards,
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 07:20 PM
тАО10-26-2005 07:20 PM
Re: Perl scriptin help
grep -i "ERROR" your_file | cut -c1-90
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 07:20 PM
тАО10-26-2005 07:20 PM
Re: Perl scriptin help
e.g. one possible way
perl -ne 'printf"%s\n", substr($_,0,30) if /error/i' /var/adm/syslog/syslog.log
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 07:23 PM
тАО10-26-2005 07:23 PM
Re: Perl scriptin help
So substitute 30 by 90 in the substr() call.
Also have a look at
perldoc -f substr
perldoc perlre
perldoc perlop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 07:54 PM
тАО10-26-2005 07:54 PM
Re: Perl scriptin help
awk '/
-Muthu
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 09:22 PM
тАО10-26-2005 09:22 PM
Re: Perl scriptin help
I need help on another scenario like.
Looking for shell command to trim the message text to length to n characters.
Each message text strings needs to be trimed to n no. of characters.
Sure you guys have some good ideas.
Thanks & Regards,
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 09:28 PM
тАО10-26-2005 09:28 PM
Re: Perl scriptin help
echo "your_string"|cut -c1-5
Will cut first 5 chars.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 09:32 PM
тАО10-26-2005 09:32 PM
Re: Perl scriptin help
#!/bin/ksh
# Input
pattern=""
count=""
file=""
grep "${pattern}" ${file} | cut -c1-${count}
# end
exit 0
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 09:42 PM
тАО10-26-2005 09:42 PM
Re: Perl scriptin help
perl -e '$count=5;$pattern="no";while(<>){ printf "%s\n", substr($_,1,$count) if /$pattern/; }'
Change $count value from 5 to your need. And $pattern from no to someother string in "".
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 10:00 PM
тАО10-26-2005 10:00 PM
Re: Perl scriptin help
Cheers,
Rajesh