LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-11-2023, 02:13 AM   #16
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,832

Rep: Reputation: 1218Reputation: 1218Reputation: 1218Reputation: 1218Reputation: 1218Reputation: 1218Reputation: 1218Reputation: 1218Reputation: 1218

The ~ is a RE match (Regular Expression).
Indeed it means "contains".
RE has got some special characters. For example, anchor characters
$1~/^timeout:$/
sais it must span from the beginning to the end. And then is identical with
$1=="timeout:"
This is a pre-selector, a condition.
Within { } there is the full awk language. You can write it like
Code:
xset q | awk '{ if ($1=="timeout:") {print $2} }'
If you have multiple columns and don't know which column it is, have a loop:
Code:
xset q | awk -v search="timeout:" '{ for (k=1;k<NF; k+=2) { if ($k == search) { print $(k+1) } } }'
Now you can also search "cycle:"
The -v assigns to an awk variable.
 
1 members found this post helpful.
Old 02-11-2023, 03:33 AM   #17
fhutt
Member
 
Registered: Oct 2015
Posts: 31

Original Poster
Rep: Reputation: Disabled
Thank you.
I think I understand now.

How do I mark the thread as [SOLVED]?
 
Old 02-11-2023, 03:43 AM   #18
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,151

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
Be aware that open systems have multiple regex engines, each slightly different - and different to one you may have used under Powershell.

To close the thread go to "Thread Tools" at the top of the thread.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
extracting a variable's value from a text file using bash savio Programming 2 02-09-2016 11:01 AM
[SOLVED] Extracting every nth line in a text file to a new text file? paradeboy Linux - General 4 03-29-2012 10:03 PM
Extracting certain lines from a text and outputting to new text files? paradeboy Linux - Newbie 4 03-14-2012 12:02 AM
read a line from text file and extracting the details needed pdklinux79 Linux - Newbie 6 06-06-2008 10:41 PM
extracting a chunk of text from a large text file lothario Linux - Software 3 02-28-2007 08:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:16 AM.

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