Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
grep | awk 2 stellen greppen
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)
View previous topic :: View next topic  
Author Message
Bender007
Tux's lil' helper
Tux's lil' helper


Joined: 11 Aug 2003
Posts: 110
Location: Göttingen

PostPosted: Fri Nov 05, 2004 8:48 am    Post subject: grep | awk 2 stellen greppen Reply with quote

hi ich versuche gerade mit grep klar zu kommen aber ich krieg nicht raus wie ich z.B. aus einer datei in der eine 5 stellige Zahl steht nur die ersten beiden ziffern greppe...

Wäre super wenn mir einer weiterhelfen könnnte...

Achso und vielleicht kennt ja jemand ein gutes faq oder howoto für grep oder awk oder wie das heisst, hab aber keine ahnung was awk genau macht aber ich glaube es hat ähnlichkeit mit grep?!
Back to top
View user's profile Send private message
papahuhn
l33t
l33t


Joined: 06 Sep 2004
Posts: 626

PostPosted: Fri Nov 05, 2004 8:54 am    Post subject: Reply with quote

Grep ist ein Kommandozeilenwerkzeug, das dir Zeilen der Standardeingabe nach Wunsch herausfiltert. awk ist eine Programmiersprache.
Back to top
View user's profile Send private message
psyqil
Advocate
Advocate


Joined: 26 May 2003
Posts: 2767

PostPosted: Fri Nov 05, 2004 9:12 am    Post subject: Reply with quote

Mit grep bekommst Du die Zeile, in der die Zahl steht, mit awk oder sed kannst Du die dann zerlegen:

http://www-106.ibm.com/developerworks/linux/library/l-sed1.html
http://www-106.ibm.com/developerworks/library/l-awk1.html
Back to top
View user's profile Send private message
Bender007
Tux's lil' helper
Tux's lil' helper


Joined: 11 Aug 2003
Posts: 110
Location: Göttingen

PostPosted: Fri Nov 05, 2004 9:32 am    Post subject: Reply with quote

also kann ich mit grep nicht die 2 stellen greppen. Die sache ist ich wollte die Temepratur aus /sys/bus/i2c/.../temp1_input auslesen und das problem ist es ist eine 5 stellige zahl wobei die 3 hinteren Zahlen nullen sind.

Also nochmal um auf grep zurückzu kommen mit grep geht es nicht also was soll ich dann benutzten awk ??

Mhh hab mir awk eben mal so n bisschen durchgelesen aber manmanman das ist ja recht.. wie soll ich sagen.. knifflig

Kann mir vielleicht einer sagen was ich am besten für n kommando benutzen soll also die datei die ich ausgeben will bzw. die ersten beiden stellen will ich ja nur ausgeben der rest also die drei nullen soll er weglassen... muss ich dann trotzdem mit grep anfangen (grep /sys/bus/i2c/.../temp1_input | awk ...)?
Back to top
View user's profile Send private message
psyqil
Advocate
Advocate


Joined: 26 May 2003
Posts: 2767

PostPosted: Fri Nov 05, 2004 10:17 am    Post subject: Reply with quote

Probier' doch mal
Code:
awk '{print substr($0,0,2)}' /sys/bus/was/auch/immer
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) 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