The UNIX and Linux Forums  

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
Using Shell Script to get data from text file jermaine4ever Shell Programming and Scripting 1 03-13-2009 08:58 PM
extracting text and reusing the text to rename file JohnDS UNIX for Dummies Questions & Answers 7 02-05-2009 03:55 AM
urgent-extracting block data from flat file using shell script shirish_cd Shell Programming and Scripting 4 02-06-2008 09:05 AM
Extracting data from text file based on configuration set in config file suparnbector Shell Programming and Scripting 3 08-10-2007 03:25 AM
Need Shell Script to upload data from Text file to Oracle database chandrashekharj Shell Programming and Scripting 6 03-26-2007 04:21 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-16-2009
jermaine4ever jermaine4ever is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 21
Script extracting the incorrect data from text file

Hello,
A script has been written to extract a specific column data from a text file ONLY if the user's initial input matches the the data of the first column in the text, then only the data from that row will be prinited.

The problem I am having is that the code is only reading the records highlighted in red from the text file. It should only read the lines where the first column matches the user’s input.

CAN ANYONE HELP?


===================Shell Script=======================

#!/bin/sh

print 'Please enter the Test Day or 0 for all days: '

read x

while read line
do
read a b c d

if a==x
then
( IFS=-
printf ' 1\n 20\n 0\n 0\n 1\n 1\n 7\n 0\n'
printf ' %s\n' $c
printf ' 1\n 1\n 0\n 0\n 0\n N\n 1\n 100\n' ) |
"$LOTO"/bin/loto_tsim > /dev/null 2>&1

print 'X is now equals to : ' $x
print 'First Col equals to : ' $a
print 'Your wager is: ' $c
fi

done < LottWagers2.txt



============= LottWagers2.txt =============

1 1 01-02-27-28-29-30 (99) Both 1
1 1 01-31-32-33-34-35 (99) Both 3
2 1 01-06-09-10-20-21 (99) Both 3
4 1 05-07-08-09-10-25 (99) Both 4
4 1 01-02-10-11-24-25 (99) Both 7
4 1 01-02-31-32-33-34 (99) Both 5
 

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:50 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