![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| reading ps command's output line by line | s. murat | Shell Programming and Scripting | 5 | 05-22-2008 01:23 AM |
| Reading the particular line from the file | eamani_sun | Shell Programming and Scripting | 3 | 05-16-2008 01:55 PM |
| reading text file line by line | MizzGail | Shell Programming and Scripting | 6 | 04-14-2008 03:58 AM |
| Reading line by line from a file | tej.buch | Shell Programming and Scripting | 2 | 01-22-2006 11:50 PM |
| Reading line by line from file. | akpopa | UNIX for Dummies Questions & Answers | 4 | 08-30-2001 07:20 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Line by line file reading... and more!
Hello,
I've got a lot of this file replication script written, but I'm having trouble finishing it off. What I need to do at the moment is run through a file one line at a time, execute the line, then check the time. The process cannot run past 7am. I've got a while loop set up to handle the time, I just need the innards of the loop to go through the file one line at a time. The file looks like this: cp /path/to/file /path/to/new/file ...... etc over and over again. Also, if it reaches 7am and the file is not completed, its remaining contents must be saved for the next night. Any help at all would be greatly appreciated. Code:
hour="`date '+%H'`"
while [ $hour -ne "07" ]
do
// read/execute next line of the file
hour="`date '+%H'`"
done
//once it is 7am, save the remainder of the file until the next night.
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
line by line reading
if you do the following it should work:-
cat "$OUTFILE" | while read LINE; do . . done where $OUTFILE is the name of your file |
|
#3
|
||||
|
||||
|
You can do something like that :
Code:
> not_proceeded_lines
hour="`date '+%H'`"
while read input_line
if [ $hour -ne "07" ]
then
echo "Proceed line ..."
hour="`date '+%H'`"
else
echo "$input_line" >> not_proceeded_lines
fi
done < input_file
Jean-Pierre. |
|
#4
|
|||
|
|||
|
alternatively you can use this:
Quote:
|
|
#5
|
||||
|
||||
|
Quote:
I already replied with a solution to the previous post: http://www.unix.com/shell-programmin...#post302128241 |
|
#6
|
|||
|
|||
|
hey i tried this script
the output is giving like this
PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE PROCEED THE LINE --------------------------------------------------------------------- the script which i tried and u have given is hour="`date '+%H'`" for filename in `cat input_line` do if [ $hour -ne "07" ] then echo "PROCEED THE LINE" hour="`date '+%H'`" else echo "$input_line" >> not_proceeded_line fi done --------------------------------------------------------------------- can u explain this , what was it doing |
|
#7
|
|||
|
|||
|
Could you please post the contents of the input_line file and not_proceeded_line file
|
|||
| Google The UNIX and Linux Forums |