LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-25-2011, 10:06 PM   #1
915086731
Member
 
Registered: Apr 2010
Posts: 144
Blog Entries: 6

Rep: Reputation: 2
Why I get no output after execute "awk '/[0-9]{4}/' fan_get.txt " ?


Hello, my question comes with the following code:
Code:
[river@localhost CLI010001]$ cat  fan_get.txt 
Source                                          Speed              Status              Mode
-------------------------------------------------------------------------------------------------------
PS A,Virtual Fan Group #1                       3600 RPM           Normal              Internal
PS A,Virtual Fan Group #1,Fan #1                2700 RPM           Normal
PS A,Virtual Fan Group #1,Fan #2                4300 RPM           Normal
PS A,Virtual Fan Group #1,Fan #3                3000 RPM           Normal
PS A,Virtual Fan Group #1,Fan #4                4300 RPM           Normal
PS A,Virtual Fan Group #1,Fan #5                3000 RPM           Normal
PS A,Virtual Fan Group #1,Fan #6                4700 RPM           Normal
PS A,Virtual Fan Group #1,Fan #7                2800 RPM           Normal
PS A,Virtual Fan Group #1,Fan #8                4400 RPM           Normal
PS B,Virtual Fan Group #2                       3500 RPM           Normal              Internal
PS B,Virtual Fan Group #2,Fan #1                2500 RPM           Normal
PS B,Virtual Fan Group #2,Fan #2                4000 RPM           Normal
PS B,Virtual Fan Group #2,Fan #3                2500 RPM           Normal
PS B,Virtual Fan Group #2,Fan #4                4300 RPM           Normal
PS B,Virtual Fan Group #2,Fan #5                2800 RPM           Normal
PS B,Virtual Fan Group #2,Fan #6                4500 RPM           Normal
PS B,Virtual Fan Group #2,Fan #7                3100 RPM           Normal
PS B,Virtual Fan Group #2,Fan #8                4400 RPM           Normal
-------------------------------------------------------------------------------------------------------

[river@localhost CLI010001]$ awk '/[0-9]{4}/' fan_get.txt 
[river@localhost CLI010001]$
Why I get no output after execute "awk '/[0-9]{4}/' fan_get.txt " ? I think many lines match it, e.g. 4400, 3100 ... ,
 
Old 08-25-2011, 11:24 PM   #2
915086731
Member
 
Registered: Apr 2010
Posts: 144

Original Poster
Blog Entries: 6

Rep: Reputation: 2
Code:
[river@localhost CLI010001]$ awk '/[0-9]\{4\}/' fan_get.txt
[river@localhost CLI010001]$
Does it means that awk does not support all the regular expression rules ?
 
Old 08-25-2011, 11:27 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Is this gawk(1) or mawk(1)? Check -
Code:
$ awk -W version
- if you are unsure.

If it's gawk(1), then turn on Posix via:
Code:
$ awk --posix '/[0-9]{4}/' foo.txt
 
1 members found this post helpful.
Old 08-26-2011, 12:28 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
The other alternative is that by default awk does not enable intervals so you can also use --re-interval. Also, if you have upgraded to version 4+ this is now in by default.
 
1 members found this post helpful.
Old 08-26-2011, 06:09 AM   #5
915086731
Member
 
Registered: Apr 2010
Posts: 144

Original Poster
Blog Entries: 6

Rep: Reputation: 2
Code:
[river@localhost CLI010004]$  awk --re-interval '/[0-9]{4}/' fan_output4.txt 
PS A,Virtual Fan Group #1                       8500 RPM           Normal              External          [52]
PS A,Virtual Fan Group #1,Fan #1                7800 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #2                9100 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #3                7600 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #4                9400 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #5                7500 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #6                9500 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #7                7700 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #8                9700 RPM           Normal                                [52]
PS B,Virtual Fan Group #2                       8700 RPM           Normal              External          [52]
PS B,Virtual Fan Group #2,Fan #1                9600 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #2                7700 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #3                9800 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #4                7800 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #5                9400 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #6                7700 RPM           Normal                                [52]
[river@localhost CLI010004]$  awk --posix '/[0-9]{4}/' fan_output4.txt 
PS A,Virtual Fan Group #1                       8500 RPM           Normal              External          [52]
PS A,Virtual Fan Group #1,Fan #1                7800 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #2                9100 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #3                7600 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #4                9400 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #5                7500 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #6                9500 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #7                7700 RPM           Normal                                [52]
PS A,Virtual Fan Group #1,Fan #8                9700 RPM           Normal                                [52]
PS B,Virtual Fan Group #2                       8700 RPM           Normal              External          [52]
PS B,Virtual Fan Group #2,Fan #1                9600 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #2                7700 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #3                9800 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #4                7800 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #5                9400 RPM           Normal                                [52]
PS B,Virtual Fan Group #2,Fan #6                7700 RPM           Normal                                [52]
[river@localhost CLI010004]$
Thanks, I should add "--posix" or "--re-interval".
Does "--posix" equals to "--re-interval" ?
 
Old 08-26-2011, 06:10 AM   #6
915086731
Member
 
Registered: Apr 2010
Posts: 144

Original Poster
Blog Entries: 6

Rep: Reputation: 2
[river@localhost CLI010004]$ awk -W version
GNU Awk 3.1.8
Copyright (C) 1989, 1991-2010 Free Software Foundation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
[river@localhost CLI010004]$ [river@localhost CLI010004]$ awk --re-interval '/[0-9]{4}/' fan_output4.txt
bash: [river@localhost: command not found...
Failed to search for file: Invalid input passed to daemon: char '[' in text!
[river@localhost CLI010004]$
 
Old 08-26-2011, 08:36 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
This page might help with regards to options.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using AWK to print out the first few lines of a txt file mskalak Linux - Newbie 3 07-27-2011 02:58 PM
[SOLVED] Bash; awk or sed output to variable: how keep newline at end of each output line porphyry5 Programming 3 06-10-2011 05:50 PM
[SOLVED] Using bash command to execute output of awk sylye Programming 12 04-03-2011 04:37 AM
[SOLVED] Simple parse txt into variables, 4 option menu, select and execute? Dimitriy Programming 13 04-27-2010 07:19 PM
How exclude | from txt.file using awk or sed? sarajevo Programming 2 08-21-2006 07:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration