- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Equivalen of perl one liner for choping columns in...
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
04-12-2010 04:52 AM
04-12-2010 04:52 AM
I have a perl one liner to determine values in specific column position to determine. To be specific, I am checking for column position 12 to 14 to be in specific value using following perl one-liner.
CNT_INV=`/usr/bin/perl -ne 'print if substr($_, 12, 2) != "87"&&substr($_, 12, 2) != "77"&&substr($_, 12, 2) != "30";' CPR_01_01_2006_G1556V01.PROCESSED|wc –l`
I would like to know equivalent shell one-linner using awk to check across feed file for column position 12 to 14 for a specific value.
Any suggestion will be much apprecialted.
Thanks,
Srikanth A
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2010 04:55 AM
04-12-2010 04:55 AM
Re: Equivalen of perl one liner for choping columns in large feed file
Sample feed contents is
0101011273043001015466506001/01/2006
0101046163027701015466506001/01/2006
The one-liner checks for specific customer number not starting with 87, 77 or 30.
Thanks,
Srikanth A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2010 05:20 AM
04-12-2010 05:20 AM
SolutionPerl's '$_' is awk's '$0' in this case. Perl counts zero-relative while awk counts one-relative.
Hence:
# echo "abcdefghijkl87op"|perl -ne 'print if substr($_,12,2) != "87"'
...becomes:
# echo "abcdefghijkl87op"|awk '{if (substr($0,13,2) != 87) {print}}
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2010 05:23 AM
04-12-2010 05:23 AM
Re: Equivalen of perl one liner for choping columns in large feed file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2010 05:26 AM
04-12-2010 05:26 AM