|
|
| apogeusistemas@gmail.com 2007-12-17, 7:21 pm |
| Hi:
How could use awk to remove all ocurrences of "Average" in a file ?
cat file
12/01/07 23:45:00 1 1 0 97
12/01/07 23:50:00 0 1 0 98
12/01/07 23:55:00 0 1 0 98
12/01/07 Average 7 2 0 90
cat file | ./script
12/01/07 23:45:00 1 1 0 97
12/01/07 23:50:00 0 1 0 98
12/01/07 23:55:00 0 1 0 98
| |
| Glenn Jackman 2007-12-17, 7:21 pm |
| At 2007-12-17 04:03PM, "apogeusistemas@gmail.com" wrote:
> Hi:
> How could use awk to remove all ocurrences of "Average" in a file ?
>
> cat file
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
> 12/01/07 Average 7 2 0 90
>
> cat file | ./script
awk '/Average/ {next} 1' file
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
| |
| Janis Papanagnou 2007-12-17, 7:21 pm |
| apogeusistemas@gmail.com wrote:
> Hi:
> How could use awk to remove all ocurrences of "Average" in a file ?
>
> cat file
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
> 12/01/07 Average 7 2 0 90
>
> cat file | ./script
Using cat is unnecessary.
./script < file
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
And putting the simple awk command in an own file seems unnecessary.
awk '!/Average/' file
or if you want to be more specific WRT the column number
awk '$2 !~ /Average/' file
Janis
| |
| Ed Morton 2007-12-19, 1:23 pm |
|
On 12/17/2007 3:03 PM, apogeusistemas@gmail.com wrote:
> Hi:
> How could use awk to remove all ocurrences of "Average" in a file ?
>
> cat file
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
> 12/01/07 Average 7 2 0 90
>
> cat file | ./script
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
No need for awk:
grep -v Average file
Ed.
| |
| mik3l3374@gmail.com 2007-12-20, 7:35 am |
| On Dec 18, 5:03 am, apogeusiste...@gmail.com wrote:
> Hi:
> How could use awk to remove all ocurrences of "Average" in a file ?
>
> cat file
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
> 12/01/07 Average 7 2 0 90
>
> cat file | ./script
>
> 12/01/07 23:45:00 1 1 0 97
> 12/01/07 23:50:00 0 1 0 98
> 12/01/07 23:55:00 0 1 0 98
not awk though
while read line
do
case $line in
*Average* ) continue ;;
*) echo $line;
esac
done < file
|
|
|
|