|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
hi everyone, on solaris 10 without gnu shell, how can i do to grep 2
word. Or 1 or 2? for example i'd like to grep all lines with Feb or Mar in this file: Fri Feb 29 12:00:00 2008: Fri Feb 29 12:30:00 2008: Fri Feb 29 13:00:01 2008: Fri Feb 29 13:30:00 2008: Sat Mar 1 04:00:00 2008: Sat Mar 1 04:30:00 2008: Sat Mar 1 05:00:00 2008: Sat Mar 1 05:30:00 2008: Sat Mar 1 06:00:00 2008: thx |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
thank you very much!!
pk ha scritto: > Patrick wrote: > > > hi everyone, on solaris 10 without gnu shell, how can i do to grep 2 > > word. Or 1 or 2? > > for example i'd like to grep all lines with Feb or Mar in this file: > > Fri Feb 29 12:00:00 2008: > > Fri Feb 29 12:30:00 2008: > > Fri Feb 29 13:00:01 2008: > > Fri Feb 29 13:30:00 2008: > > Sat Mar 1 04:00:00 2008: > > Sat Mar 1 04:30:00 2008: > > Sat Mar 1 05:00:00 2008: > > Sat Mar 1 05:30:00 2008: > > Sat Mar 1 06:00:00 2008: > > egrep 'Feb|Mar' file.txt > > or > > awk '/Feb/ || /Mar/' file.txt > > -- > All the commands are tested with bash and GNU tools, so they may use > nonstandard features. I try to mention when something is nonstandard (if > I'm aware of that), but I may miss something. Corrections are welcome. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Patrick wrote:
> hi everyone, on solaris 10 without gnu shell, how can i do to grep 2 > word. Or 1 or 2? > for example i'd like to grep all lines with Feb or Mar in this file: > Fri Feb 29 12:00:00 2008: > Fri Feb 29 12:30:00 2008: > Fri Feb 29 13:00:01 2008: > Fri Feb 29 13:30:00 2008: > Sat Mar 1 04:00:00 2008: > Sat Mar 1 04:30:00 2008: > Sat Mar 1 05:00:00 2008: > Sat Mar 1 05:30:00 2008: > Sat Mar 1 06:00:00 2008: egrep 'Feb|Mar' file.txt or awk '/Feb/ || /Mar/' file.txt -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
pk schreef:
> Patrick wrote: > >> hi everyone, on solaris 10 without gnu shell, how can i do to grep 2 >> word. Or 1 or 2? >> for example i'd like to grep all lines with Feb or Mar in this file: >> Fri Feb 29 12:00:00 2008: >> Fri Feb 29 12:30:00 2008: >> Fri Feb 29 13:00:01 2008: >> Fri Feb 29 13:30:00 2008: >> Sat Mar 1 04:00:00 2008: >> Sat Mar 1 04:30:00 2008: >> Sat Mar 1 05:00:00 2008: >> Sat Mar 1 05:30:00 2008: >> Sat Mar 1 06:00:00 2008: > > egrep 'Feb|Mar' file.txt > > or > > awk '/Feb/ || /Mar/' file.txt > awk '/Feb|Mar/' file.txt also seems to work... -- Luuk |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Luuk wrote:
>> awk '/Feb/ || /Mar/' file.txt >> > > awk '/Feb|Mar/' file.txt > > also seems to work... Ah yes, of course. Thanks! -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 2008-03-19, Patrick wrote:
> hi everyone, on solaris 10 without gnu shell, how can i do to grep 2 > word. Or 1 or 2? > for example i'd like to grep all lines with Feb or Mar in this file: > Fri Feb 29 12:00:00 2008: > Fri Feb 29 12:30:00 2008: > Fri Feb 29 13:00:01 2008: > Fri Feb 29 13:30:00 2008: > Sat Mar 1 04:00:00 2008: > Sat Mar 1 04:30:00 2008: > Sat Mar 1 05:00:00 2008: > Sat Mar 1 05:30:00 2008: > Sat Mar 1 06:00:00 2008: grep -e Feb -e Mar FILE -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
![]() |
| Outils de la discussion | |
|
|