Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to grep a line not starting with # from a file (there are two lines starting with # and normal)? Post 302974496 by RavinderSingh13 on Tuesday 31st of May 2016 07:49:18 AM
Old 05-31-2016
Quote:
Originally Posted by Tanu
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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to remove all lines from a file before a line starting with pattern

hi,, i hav a file with many lines.i need to remove all lines before a line begginning with a specific pattern from the file because these lines are not required. Can u help me out with either a perl script or shell script example:- if file initially contains lines: a b c d .1.2 d e f... (2 Replies)
Discussion started by: raksha.s
2 Replies

2. Shell Programming and Scripting

Grep from a starting line till the end of the file

Hi Folks, I got to know from this forums on how to grep from a particular line say line 6 awk 'NR==6 {print;exit}' But how do i grep from line 6 till the end of the file or command output. Thanks, (3 Replies)
Discussion started by: Mr. Zer0
3 Replies

3. Shell Programming and Scripting

Read .txt file and dropping lines starting with #

Hi All, I have a .txt file with some contents as below: Hi How are you? # Fine and you? I want a script file which reads the .txt file and output the lines which does not start with #. Hi How are you? Help is highly appreciated. Please use code tags when posting data and... (5 Replies)
Discussion started by: bghosh
5 Replies

4. Shell Programming and Scripting

AWK/GREP: grep only lines starting with integer

I have an input file 12.4 1.72849432773174e+01 -7.74784188610632e+01 12.5 9.59432114416327e-01 -7.87018212757537e+01 15.6 5.20139995965960e-01 -5.61612429666624e+01 29.3 3.76696387248366e+00 -7.42896194101892e+01 32.1 1.86899877018077e+01 -7.56508762501408e+01 35 6.98857157014640e+00... (2 Replies)
Discussion started by: chrisjorg
2 Replies

5. UNIX for Dummies Questions & Answers

Grep only line starting with....

Hello, I have a command that show some application information. Now, I have to grep there informations, like: # showlog | grep 1266 1266.1369866124 :: 1266.1304711286 :: 41031.1161812668 :: 41078.1301266480 :: 41641.712662564 :: 1266.333792515 :: 41462.1512661988 :: 1266.54932671... (5 Replies)
Discussion started by: Lord Spectre
5 Replies

6. Shell Programming and Scripting

Matching and Replacing file lines starting with $

Here is the task that I was presented with: I am dealing with about a 10,000 line input deck file for an analysis. About 10 separate blocks of around 25 lines of code each need to be updated in the input deck. The input deck (deckToChange in the code below) comes with 2 separate files. File 1... (5 Replies)
Discussion started by: tiktak292
5 Replies

7. Shell Programming and Scripting

Grep command to ignore line starting with hyphen

Hi, I want to read a file line by line and exclude the lines that are beginning with special characters. The below code is working fine except when the line starts with hyphen (-) in the file. for TEST in `cat $FILE | grep -E -v '#|/+' | awk '{FS=":"}NF > 0{print $1}'` do . . done How... (4 Replies)
Discussion started by: Srinraj Rao
4 Replies

8. Shell Programming and Scripting

With script bash, read file line per line starting at the end

Hello, I'm works on Ubuntu server My goal : I would like to read file line per line, but i want to started at the end of file. Currently, I use instructions : while read line; do COMMAND done < /var/log/apache2/access.log But, the first line, i don't want this. The file is long... (5 Replies)
Discussion started by: Fuziion
5 Replies

9. UNIX for Beginners Questions & Answers

Grep file starting from pattern matching line

I have a file with a list of references towards the end and want to apply a grep for some string. text .... @unnumbered References @sp 1 @paragraphindent 0 2017. @strong{Chalenski, D.A.}; Wang, K.; Tatanova, Maria; Lopez, Jorge L.; Hatchell, P.; Dutta, P.; @strong{Small airgun... (1 Reply)
Discussion started by: kristinu
1 Replies

10. Shell Programming and Scripting

Delete all lines except a line starting with string

Shell : bash OS : RHEL 6.8 I have a file like below. $ cat pattern.txt hello txt1 txt2 txt3 some other text txt4 I want to remove all lines in this file except the ones starting with txt . How can I do this ? (4 Replies)
Discussion started by: omega3
4 Replies
Mojo::Asset::File(3pm)					User Contributed Perl Documentation				    Mojo::Asset::File(3pm)

NAME
Mojo::Asset::File - File storage for HTTP 1.1 content SYNOPSIS
use Mojo::Asset::File; # Temporary file my $file = Mojo::Asset::File->new; $file->add_chunk('foo bar baz'); say 'File contains "bar"' if $file->contains('bar') >= 0; say $file->slurp; # Existing file my $file = Mojo::Asset::File->new(path => '/home/sri/foo.txt'); $file->move_to('/yada.txt'); say $file->slurp; DESCRIPTION
Mojo::Asset::File is a file storage backend for HTTP 1.1 content. ATTRIBUTES
Mojo::Asset::File inherits all attributes from Mojo::Asset and implements the following new ones. "cleanup" my $cleanup = $file->cleanup; $file = $file->cleanup(1); Delete file automatically once it's not used anymore. "handle" my $handle = $file->handle; $file = $file->handle(IO::File->new); File handle, created on demand. "path" my $path = $file->path; $file = $file->path('/home/sri/foo.txt'); File path used to create "handle", can also be automatically generated if necessary. "tmpdir" my $tmpdir = $file->tmpdir; $file = $file->tmpdir('/tmp'); Temporary directory used to generate "path", defaults to the value of the "MOJO_TMPDIR" environment variable or auto detection. METHODS
Mojo::Asset::File inherits all methods from Mojo::Asset and implements the following new ones. "add_chunk" $file = $file->add_chunk('foo bar baz'); Add chunk of data. "contains" my $position = $file->contains('bar'); Check if asset contains a specific string. "get_chunk" my $chunk = $file->get_chunk($start); Get chunk of data starting from a specific position. "is_file" my $true = $file->is_file; True. "move_to" $file = $file->move_to('/home/sri/bar.txt'); Move asset data into a specific file and disable "cleanup". "size" my $size = $file->size; Size of asset data in bytes. "slurp" my $string = $file->slurp; Read all asset data at once. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Asset::File(3pm)
All times are GMT -4. The time now is 07:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy