The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Searching all files that contain pattern ravi.sadani19 Shell Programming and Scripting 4 11-29-2008 06:52 PM
Pattern searching pattern in c files murthybptl Shell Programming and Scripting 6 11-17-2007 09:15 AM
How to use cat command in sed pattern searching Sona UNIX for Dummies Questions & Answers 4 08-22-2006 09:05 AM
Searching for a pattern in a Directory gandhevinod Filesystems, Disks and Memory 1 02-25-2005 08:35 AM
pattern searching using C giannicello High Level Programming 1 04-16-2002 12:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-29-2006
sbasetty sbasetty is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 75
Regarding Searching Pattern

Hi Guys,

Can you help with the shell script:
I would like to search a fixed width pattern from a file
say for each line from a fixed position and lenght it has to return all rows from the file.


Example:
To search the third column for "def" it has to return 1 and 4th rows only

1|abc|def|hgd|sda|XYZ|sdd
2|FSD|sdf|fds|def|ads|XYZ
3|has|sdg|ret|def|asd|SDF
4|fsd|def|gsh|def|hjf|6545
5|sdf|hdf|def|fdg|8747389|736
6|def|dfs|dsg|def|837|dsg"|388


I have tried using "awk"
is there a way we can combine substr and awk.


Thanks in advance.
Sat.
  #2 (permalink)  
Old 09-29-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
awk -F"|" ' $3 == "def" { print $0 }' f
  #3 (permalink)  
Old 09-29-2006
sbasetty sbasetty is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 75
Great!!!


Thank you very much

Sat.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0