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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-19-2008
raoscb raoscb is offline
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.
  #2 (permalink)  
Old 05-19-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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.
  #3 (permalink)  
Old 05-19-2008
raoscb raoscb is offline
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.
  #4 (permalink)  
Old 05-19-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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 09:21 AM.. Reason: egrep -i to ignore case
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 07:51 AM.


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