![]() |
|
|
|
|
|||||||
| 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 |
| Problem in For Loop | The Observer | Shell Programming and Scripting | 2 | 05-27-2008 11:43 PM |
| for loop problem | namishtiwari | Shell Programming and Scripting | 5 | 01-25-2008 09:58 AM |
| loop problem | maskot | Shell Programming and Scripting | 1 | 05-25-2007 01:10 AM |
| Problem with for loop/sed ? | chiru_h | Shell Programming and Scripting | 2 | 08-27-2006 08:55 AM |
| problem with while loop | mridula | High Level Programming | 1 | 12-11-2005 08:44 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
awk and loop problem
Good morning,
Sir's i would like to ask for help regarding to my awk and loop problem, a script that will check my files a and b then if it will see there was a time below 3am it will echo the file that contains below 3am file, for this example it will redirect the file a to an output. $ cat a Sun Feb 3 08:49:01 EAT 2008 Sun Feb 3 12:09:33 EAT 2008 Mon Feb 4 01:44:48 EAT 2008 Mon Feb 4 13:02:00 EAT 2008 $cat b Sat Feb 2 08:14:34 EAT 2008 Sat Feb 2 09:55:36 EAT 2008 Sun Feb 3 08:44:13 EAT 2008 Sun Feb 3 09:46:38 EAT 2008 Mon Feb 4 07:43:09 EAT 2008 Mon Feb 4 09:41:24 EAT 2008 desired output: file a has below 3 am. Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Try...
Code:
awk -F '[ :]' '$4+0<n{printf "File %s below %s\n", FILENAME, n}' n=3 a b
|
|
#3
|
||||
|
||||
|
Do you have to use awk here? This will work too:
Code:
while read one two three four rest; do
if [ ${four%%:*} -lt 3 ]; then
echo file a has below 3 am;
break;
fi;
done < a
while read one two three four rest; do
if [ ${four%%:*} -lt 3 ]; then
echo file b has below 3 am;
break;
fi;
done < b
|
|
#4
|
|||
|
|||
|
great! thanks to all
|
|||
| Google The UNIX and Linux Forums |