Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

UNIX for Dummies Questions & Answers


Tags
solved

 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-31-2016
Tanu Tanu is offline
Registered User
 
Join Date: May 2016
Last Activity: 7 September 2017, 4:27 PM EDT
Posts: 15
Thanks: 8
Thanked 1 Time in 1 Post
How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g.

File name: File.txt
Code:
cat File.txt

Result:

Code:
#INBOUND_QUEUE=FAQ1          
INBOUND_QUEUE=FAQ2

I want to get the value for one which is not commented out.

Thanks,

Last edited by vbe; 05-31-2016 at 08:27 AM..
Sponsored Links
    #2  
Old Unix and Linux 05-31-2016
RavinderSingh13 RavinderSingh13 is online now Forum Advisor  
Registered User
 
Join Date: May 2013
Last Activity: 20 October 2017, 3:53 PM EDT
Location: Chennai
Posts: 2,634
Thanks: 582
Thanked 1,253 Times in 1,128 Posts
Quote:
Originally Posted by Tanu View Post
e.g.
File name: File.txt
cat File.txt
Result:
#INBOUND_QUEUE=FAQ1
INBOUND_QUEUE=FAQ2
I want to get the value for one which is not commented out.
Thanks,
Hello Tanu,

Welcome to forums, please use code tags for commands/cods/Inputs as per forum rules. Following may help you in same.

Code:
awk '/^#/{next} 1'  Input_file
OR
awk '/^#/{next} 1'  File.txt

Thanks,
R. Singh
Sponsored Links
    #3  
Old Unix and Linux 05-31-2016
Tanu Tanu is offline
Registered User
 
Join Date: May 2016
Last Activity: 7 September 2017, 4:27 PM EDT
Posts: 15
Thanks: 8
Thanked 1 Time in 1 Post
Thanks .. Let me try Linux

---------- Post updated at 07:18 AM ---------- Previous update was at 06:52 AM ----------

Thanks R.Singh for quick response..your solution worked perfectly (y)
    #4  
Old Unix and Linux 05-31-2016
os2mac's Unix or Linux Image
os2mac os2mac is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 6 October 2017, 8:09 PM EDT
Location: Anchorage, AK
Posts: 244
Thanks: 20
Thanked 25 Times in 25 Posts
grep -v '^#'
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep command to ignore line starting with hyphen Srinraj Rao Shell Programming and Scripting 4 06-19-2015 01:36 AM
Grep only line starting with.... Lord Spectre UNIX for Dummies Questions & Answers 5 07-24-2013 10:21 AM
AWK/GREP: grep only lines starting with integer chrisjorg Shell Programming and Scripting 2 04-17-2012 10:06 AM
Grep from a starting line till the end of the file Mr. Zer0 Shell Programming and Scripting 3 09-13-2010 09:06 PM
shell script to remove all lines from a file before a line starting with pattern raksha.s Shell Programming and Scripting 2 03-29-2009 07:13 AM



All times are GMT -4. The time now is 04:03 PM.