Why I get no output after execute "awk '/[0-9]{4}/' fan_get.txt " ?
Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 ... ,
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.
[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" ?
[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]$
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.