|
Re: [Lug-bg] Въпрос за bash скриптче.
- Subject: Re: [Lug-bg] Въпрос за bash скриптче.
- From: Yordan Boikov <boikov@xxxxxxxxx>
- Date: Tue, 09 Jun 2009 13:54:05 +0300
значи трябва да стане:
$2 и $13
debian-work:~# awk '{if ($2 > 5000) print $13}' iptables_out > произволен_фаил
Quoting Kristian Kirilov <d3v1ous@xxxxxxxxxxxx>:
> Damyan Ivanov wrote:
>> -=| Kristian Kirilov, Tue, Jun 09, 2009 at 12:35:00PM +0300 |=-
>>
>>> Здравейте, имам следния резултат
>>>
>>> 5001 1001
>>> 4001 1002
>>> 5002 102
>>> 5003 1032
>>> 5004 1011
>>> 121 1000
>>> 12345 1008
>>> 1234 1010
>>>
>>> В този случай как мога да направя условие което да сравнява първата
>>> колона с числото 5000, и тя го надвишава числото от 2-рата колона на
>>> същия ред да се запише в произволен файл.
>>>
>>> Т.е. изхода трябва да излгежда нещо от сорта:
>>>
>>> 1001
>>> 102
>>> 1032
>>> 1011
>>> 1008
>>>
>>
>> ---------------------------
>> #!/bin/sh
>>
>> while read a b; do
>> if [ $a -gt 5000 ]; then
>> echo $b
>> fi
>> fi
>> ---------------------------
>>
>> script < входен-файл > изходен-файл
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Lug-bg mailing list
>> Lug-bg@xxxxxxxxxxxxxxxxxx
>> http://linux-bulgaria.org/mailman/listinfo/lug-bg
>>
> debian-work:~# cat iptables_out
> 27 5001 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 owner UID match 1001 MARK
> xset 0x1/0xffffffff
> 21 4001 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 owner UID match 1002 MARK
> xset 0x1/0xffffffff
> 27 5002 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 owner UID match 102 MARK
> xset 0x1/0xffffffff
> 27 5003 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 owner UID match 1032 MARK
> xset 0x1/0xffffffff
> 27 5004 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 owner UID match 1011 MARK
> xset 0x1/0xffffffff
> 21 121 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 owner UID match 1000 MARK
> xset 0x1/0xffffffff
> 21 12345 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 owner UID match 1008 MARK
> xset 0x1/0xffffffff
> 21 1234 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 owner UID match 1010 MARK
> xset 0x1/0xffffffff
> debian-work:~# cat test
> #!/bin/sh
>
> while read a b; do
> if [ $a -gt 5000 ]; then
> echo $b
> fi
> fi
> debian-work:~# ./test iptables_out proba
> ./test: line 7: syntax error near unexpected token `fi'
> ./test: line 7: `fi'
> debian-work:~#
>
> Второто fi не трябва ли да бъде done?
>
> Опитах с done, резултата не беше по добър :)
>
> debian-work:~# cat test
> #!/bin/sh
>
> while read a b; do
> if [ $a -gt 5000 ]; then
> echo $b
> fi
> done
> debian-work:~#
>
> debian-work:~# ./test iptables_out proba
>
> ./test: line 4: [: -gt: unary operator expected
>
> ./test: line 4: [: -gt: unary operator expected
>
> ./test: line 4: [: -gt: unary operator expected
> ^C
>
> Поздрави
> К.Кирилов
> _______________________________________________
> Lug-bg mailing list
> Lug-bg@xxxxxxxxxxxxxxxxxx
> http://linux-bulgaria.org/mailman/listinfo/lug-bg
>
--
Yordan Boikov
:wq
_______________________________________________
Lug-bg mailing list
Lug-bg@xxxxxxxxxxxxxxxxxx
http://linux-bulgaria.org/mailman/listinfo/lug-bg
|
|
|