![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to search for files based on the time stamp | sunny_03 | UNIX for Dummies Questions & Answers | 1 | 02-12-2008 09:45 AM |
| Using find command for timestamp based search | sunny_03 | UNIX for Dummies Questions & Answers | 1 | 02-12-2008 05:38 AM |
| column based search | user_007 | Shell Programming and Scripting | 8 | 07-01-2007 05:52 AM |
| Using egrep to search for Text and special char | izy100 | UNIX for Advanced & Expert Users | 2 | 11-04-2005 09:55 PM |
| search for hardlinks based on filename via find command | hunternjb | UNIX for Dummies Questions & Answers | 2 | 03-27-2001 12:07 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
I want to search for the very first character in a row from the file.
It is very similar to the way we use Mainframes File-Aid, quick search option. I couldnt find anything helpful with the grep command. Does any one has an idea, how to perform this? |
|
||||
|
Zazzybob
Though this solves my purpoase, In future I might need to carry a search on criterias say on 10th character or on 22nd character & 3 chars wide. I still dont find logic to associate help on grep, to solve the above problems also. |
|
|||||
|
Indeed, regular expressions can be your best friend or worst enemy. Take the time to learn them as they are *very* powerful. Here are some links from the front page of a google search - (NOTE: I haven't checked - and therefore do not endorse - these links
)http://www.robelle.com/library/smugbook/regexpr.html http://sitescooper.org/tao_regexps.html http://www.grymoire.com/Unix/Regular.html Beware that some regex constructs are specific to perl/sed/grep etc... Cheers ZB |
|
||||
|
Hi All,
With the links provided by Zazzybob, I could find a solution. cat filename | cut -c m-n | grep '^String' Let me explain - cat command opens file with the name provided in loc of filename. cut command cuts the characters from the range provided from m to n. Please note the very first char has an index as 1. On these cut contents carry out search operation, from beginning as mentioned by ^, with the string in interest mentioned as 'String'. And all you get is an expected result at console. If anyone has a better approach than this, please share. |
![]() |
| Bookmarks |
| Tags |
| perl, perl regex, regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|