- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grepping a specific column ???
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
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
тАО05-25-2001 08:16 AM
тАО05-25-2001 08:16 AM
Can anyone advise on a command or script which will read through a large file line by line extracting lines which contain a specific strings of characters which appear between certain places on a line.
e.g grep abcde filename1 > filename2 works, but I only want not look in characters 5-10 of each line and no where else on the line.
Many thanks
Solved! Go to Solution.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 08:19 AM
тАО05-25-2001 08:19 AM
Re: grepping a specific column ???
cut -c5-10 filename1 | grep findthis
- Tags:
- cut
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 08:21 AM
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 08:22 AM
тАО05-25-2001 08:22 AM
Re: grepping a specific column ???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 08:33 AM
тАО05-25-2001 08:33 AM
Re: grepping a specific column ???
try this
cat filename | awk '{ print $5 } | cut -c5-10
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 08:35 AM
тАО05-25-2001 08:35 AM
Re: grepping a specific column ???
awk 'substr($0,5,5)="datum"{print $0}' your_file
awk can compare a substring and then print only thos lines
or
perl -nie 'print if substr($_,4,5) eq "datum"'
perl can also compare a substring and then print
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 09:13 AM
тАО05-25-2001 09:13 AM
Re: grepping a specific column ???
awk ' $2 == "data" { print $0 }' file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 06:42 PM
тАО05-25-2001 06:42 PM
Re: grepping a specific column ???
Try using a regular expression:
grep ".....abcde" file1 > file2
The . wil match any single character. You could probably get away with the following, which would guard against the wrong number of "dots":
grep ".\{5\}abcdef" file1 > file2
See the regexp(5) and the grep(1) man pages for more information.
--Bruce