Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[OT] bash regex macht mich wahnsinnig...
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum
View previous topic :: View next topic  
Author Message
suro
n00b
n00b


Joined: 28 Oct 2003
Posts: 64
Location: Austria

PostPosted: Thu Oct 28, 2004 11:13 pm    Post subject: [OT] bash regex macht mich wahnsinnig... Reply with quote

sorry für die späte störung, das thema passt auch nicht ganz hier her, weis
aber nicht wo ich sonst noch so spät kompetente hilfe bekomme :wink:

ich möchte mir aus einem file welches mehrere zeilen mit buchstaben und zahlen
enthält nur all jene anzeigen lassen, die "keine" buchstaben enthalten!

das muss doch mit einem "cat file | grep _regex_" möglich sein???!!

ein beispieltext:
Code:
hallo
22 333 4444
hallo 2
3 hallo
44 55 55
000 hallo
6


hier möchte ich z.b. nur die zeilen 2, 5 und 7 (keine buchstaben in diesen zeilen)

spiel mich schon mit allen möglichen varianten (^[:alpha:], etc.), komm aber leider nicht dahinter!

danke schon mal an alle noch wachen (evt arbeitenden, so wie ich)!

lg
suro

mod edit: + [OT]
amne
Back to top
View user's profile Send private message
steveb
Advocate
Advocate


Joined: 18 Sep 2002
Posts: 4564

PostPosted: Thu Oct 28, 2004 11:38 pm    Post subject: Reply with quote

Code:
grep "^[0-9 ]*$" file
Back to top
View user's profile Send private message
suro
n00b
n00b


Joined: 28 Oct 2003
Posts: 64
Location: Austria

PostPosted: Thu Oct 28, 2004 11:56 pm    Post subject: Reply with quote

DANKE!

du hast mir eben noch ein paar nerven geschont :wink: :wink:
Back to top
View user's profile Send private message
steveb
Advocate
Advocate


Joined: 18 Sep 2002
Posts: 4564

PostPosted: Fri Oct 29, 2004 12:19 am    Post subject: Reply with quote

suro wrote:
DANKE!

du hast mir eben noch ein paar nerven geschont :wink: :wink:
Bleib Locker ;)

<klugscheiss>An Computern kann man kaum Nerven verlieren.</klugscheiss>

<inronie>Frauen sind da ein besseres Gebiet, um Nerven zu verlieren.</inronie>


Gruss

Steve
Back to top
View user's profile Send private message
smg
Veteran
Veteran


Joined: 13 Aug 2004
Posts: 1402
Location: /home/stephan

PostPosted: Fri Oct 29, 2004 9:08 am    Post subject: Reply with quote

Außerdem machst du dort keinen Regex mit Bash, sondern benutzt grep mit einem regex.
Du kannst dir gerne mal ABS durchlesen unter:

Code:
<newbie-bot> abs: http://www.tldp.org/LDP/abs/html/
<newbie-bot> abs: ist auch im portage tree unter app-doc/abs-guide
<newbie-bot> abs: Advanced Bash Scripting Guide


viel glück :)

# mfg
_________________
GnuPG-Key-ID: 0xF8C275D4
Fingerprint: 5B6F 134A 189B A24D 342B 0961 8D4B 0230 F8C2 75D4
Code:
perl -WTe '($")=$/;print qq(@{[reverse('0'..'100')]}$/BOOM!$/);'
Back to top
View user's profile Send private message
DerMojo
Guru
Guru


Joined: 14 Aug 2003
Posts: 395
Location: Germany

PostPosted: Fri Oct 29, 2004 9:31 am    Post subject: Reply with quote

Hi!

Nur so P.S.: ich hätte
Code:
grep -v '[[:alpha:]]'

genommen, ist irgendwie simpler, wenn man etwas _nicht_ haben will.

MfG
Daniel
_________________
To err is human, to forgive, beyond the scope of the Operating System.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum