The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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
read command COD Shell Programming and Scripting 4 04-26-2008 01:49 PM
help with READ command fiol73 UNIX for Dummies Questions & Answers 2 12-15-2006 11:13 AM
REad Command bourne Shell Programming and Scripting 2 06-19-2006 07:02 AM
AWK : read unix command fwirbel Shell Programming and Scripting 6 02-08-2005 05:11 AM
Cat and read command mango Shell Programming and Scripting 3 12-29-2003 10:55 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-19-2008
Registered User
 

Join Date: May 2008
Posts: 16
Question need help on how to read command in unix

can any one please help me how to use "read" command for openig a file.i want to process the file record by record and then needs to search for a particular string at a particular position.can any one please let me know the code.i am new to the shell.

below are sample sample records

D6303200805066HJ8164-61002EURO6303I0073554514
D6303200805066HJ8164-61002EURO6303I0073554514

your help would appreciate.....


thanks
rao.
Reply With Quote
Forum Sponsor
  #2  
Old 05-19-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
read simply reads standard input. You probably want to use redirection.

Code:
while read line; do
  echo "Read line '$line'"
done <file
Without concrete information about which particular string at which particular position, it's hard to do anything useful inside that loop, but it should hopefully be enough to get you started.
Reply With Quote
  #3  
Old 05-19-2008
Registered User
 

Join Date: May 2008
Posts: 16
Exclamation need help on how to read command in unix

thanks ray.
i have seen the below code.but i am not getting wht the "line" signifies in the read command?i am very new to unix scripting.could you please write elabrately somethign in the code.
coming to search pattern i have to search at 14and15 postion of the record whether it equals to '6h' or not.if so i have to write that coressponding record into a separate file.

i really appreciate your help.

advancedthanks
narasimharao.
Reply With Quote
  #4  
Old 05-19-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
If that's all you need, read is not really appropriate.

Code:
egrep '^.{13,14}6h' file >separatefile
(Or 6H if that's what you really mean; grep and friends are case sensitive by default. Add the -i option to ignore case distinctions.)

read variablename reads a line of input, which is subsequently available in $variablename -- you can of course call your variables anything you like.

("ray", huh? Had't come across that particular one before ...)

Last edited by era; 05-19-2008 at 05:21 AM. Reason: egrep -i to ignore case
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0