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
read user input from within a wile loop that is being fed from below broli UNIX for Dummies Questions & Answers 2 01-09-2008 03:19 PM
ls while read loop - internal read picking up wrong input dkieran Shell Programming and Scripting 2 05-14-2007 03:02 PM
how to get input from file ajaya Shell Programming and Scripting 1 04-05-2006 02:02 PM
input inside while read loop jhansrod Shell Programming and Scripting 3 08-13-2005 10:46 AM
TCSH.need help.take input during a while/end loop seg Shell Programming and Scripting 1 08-28-2003 03:41 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 08-15-2007
sytycd712 sytycd712 is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 2
need help with using input file in the while loop

here's my code:

ls -lt | /usr/bin/egrep `date +"%Y%m%d(05|06|07|08|09|10|11|12|13|14|15|16|17|18|19)"` | \
/usr/bin/egrep -i .dat | /usr/bin/awk '{print $9}' > $LockboxFile1

if [[ -s $LockboxFile1]]
then
echo " "
echo "Files in the archived directory: "
cat $LockboxFile1 |
while read line
do
grep -l CHK $line >> $LockboxFile2
done
fi

it's erroring out, would anyone know why it's not working?
  #2 (permalink)  
Old 08-15-2007
sytycd712 sytycd712 is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 2
tried this one too

ls -lt | /usr/bin/egrep `date +"%Y%m%d(05|06|07|08|09|10|11|12|13|14|15|16|17|18|19)"` | \
/usr/bin/egrep -i .dat | /usr/bin/awk '{print $9}' > $LockboxFile1


cat $LockboxFile1 | while read line
do
grep -l CHK $line
done >> $LockboxFile2

it's giving me an error: done unexpected

cat $LockboxFile1 | while read line
do
grep -l CHK $line
:
done >> $LockboxFile2

it's giving me an error: done unexpected

-- but i tried to run this in unix and it returned the output I am expecting, it's just not working when i add and run in the ksh script i am working on
  #3 (permalink)  
Old 08-15-2007
lorcan lorcan is offline
Registered User
  
 

Join Date: May 2007
Posts: 219
Try

Code:
while read line 
do 
grep -l CHK $line >> $LockboxFile2 
:
done < $LockboxFile1
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 02:25 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