LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-05-2004, 03:27 PM   #1
dtheorem
Member
 
Registered: Sep 2003
Location: Winnipeg, MB, CA
Distribution: LinuxMint
Posts: 101

Rep: Reputation: 15
How to search for asterisks using gawk


I want to use gawk to search for asterisks within a file, call it error.txt
I write:

gawk '/*/' error.txt >> error2.txt

of course it copies everything to error2 because * is a wildcard. However, I would like to search for lines containing a literal asterisk. This must be possible somehow. I prefer not to use sed to change the asterisks.
 
Old 03-05-2004, 03:35 PM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
When searching for special characters like that, it's necessary to 'escape' the character by preceding it with a backslash '\'. That tells gawk (and most other programs which deal with regular expressions) to treat the next character literally. Like so:

gawk '/\*/' error.txt >> error2.txt
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel preemption error installing Zaptel for Asterisks neutrin0 Linux - Software 1 11-13-2005 02:10 AM
font + asterisks password childish Linux - Newbie 9 06-24-2005 04:24 PM
converting string to asterisks pantera Programming 2 09-13-2004 02:27 PM
gawk search parameters dtheorem Linux - General 1 03-10-2004 05:41 PM
Linux...Modems...Asterisks PBX tadd Linux - Hardware 0 12-02-2003 09:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:03 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