Sponsored Content
Top Forums Shell Programming and Scripting awk - print file contents except regex Post 302222822 by rmsagar on Thursday 7th of August 2008 02:20:58 PM
Old 08-07-2008
awk - print file contents except regex

Hello,
I have a file which has user information. Each user has 2 variables with the same name like
Email: testuser1
Email: testuser1@test.com
Email: testuser2
Email: testuser2@test.com
My intention is to delete the ones without the '@' symbol. When I run this statement awk '/^Email:/&&!/@/' <FileName>. It prints all the Email variable without the @. But when I try to run this one expecting to print all the lines except Email without @. it prints everything.
awk '/cn:/&&!/@/ { copy=1 }; copy { print } ' <filename>

Please advise.

-Regards,
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using first word and print their contents using awk

suppose u hava a file G1354R tGGC-CGC D1361N cGAC-AAC I1424T ATC-ACC R768W gCGG-TGG Q1382R CAG-CGG Q178E gCAG-GAG Y181C TAC-TGC .........cont. So the question is By searching for first word i.e.character say R output shud be R768W gCGG-TGG R182P CGG-CCG R189W ... (6 Replies)
Discussion started by: cdfd123
6 Replies

2. UNIX for Advanced & Expert Users

print contents of file2 for matching pattern in file1 - AWK

File1 row is same as column 2 in file 2. Also file 2 will either start with A, B or C. And 3rd column in file 2 is always F2. When column 2 of file 2 matches file1 column, print all those rows into a separate file. Here is an example. file 1: 100 103 104 108 file 2: ... (6 Replies)
Discussion started by: i.scientist
6 Replies

3. Shell Programming and Scripting

Read contents of the file and print

AT ---------- 0 Elapsed: 00:00:00.02 SO ---------- 0 Elapsed: 00:00:00.01 SE ---------- 0 Elapsed: 00:00:00.01 CR ---------- (4 Replies)
Discussion started by: sandy1028
4 Replies

4. Shell Programming and Scripting

need to grep contents of a file within specific time span. regex i am using is not working

Hi , I am trying to extract contents of a file between specified time stamp. but it does not seem to work. i am trying to extract output of /var/adm/messages between 15:00:00 to 15:23:59 . i have tried two regex the first one seems to kind of work. it displays some output. the second one is... (13 Replies)
Discussion started by: chidori
13 Replies

5. Shell Programming and Scripting

awk: compose regex in variable and then use its contents like $0 ~ var

A question to the awk pundits: I was thinking about composing a regex in a variable and then use its contents like $0 ~ var instead of $0 ~ /r/. Sort of indirection. Did someone run into this? Is it possible at all? (3 Replies)
Discussion started by: RudiC
3 Replies

6. UNIX for Dummies Questions & Answers

read regex from ID file, print regex and line below from source file

I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header. In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

7. Shell Programming and Scripting

To print lines between 2 timestamps using awk|sed and regex

Hi, I am using the following code to fetch lines that are generated in last 1 hr . Hence, I am using date function to calculate -last 1 hr & the current hr and then somehow use awk (or sed-if someone could guide me better) with some regex pattern. dt_1=`date +%h" "%d", "%Y\ %l -d "1 hour... (10 Replies)
Discussion started by: sarah-alikhan31
10 Replies

8. Shell Programming and Scripting

For loop inside awk to read and print contents of files

Hello, I have a set of files Xfile0001 - Xfile0021, and the content of this files (one at a time) needs to be printed between some line (lines start with word "Generated") that I am extracting from another file called file7.txt and all the output goes into output.txt. First I tried creating a for... (5 Replies)
Discussion started by: jaldo0805
5 Replies

9. UNIX for Advanced & Expert Users

awk print all fields except matching regex

grep -v will exclude matching lines, but I want something that will print all lines but exclude a matching field. The pattern that I want excluded is '/mnt/svn' If there is a better solution than awk I am happy to hear about it, but I would like to see this done in awk as well. I know I can... (11 Replies)
Discussion started by: glev2005
11 Replies

10. Shell Programming and Scripting

(n)awk: print regex search output lines in one line

Hello. I have been looking high and low for the solution for this. I seems there should be a simple answer, but alas. I have a big xml file, and I need to extract certain information from specific items. The information I need can be found between a specific set of tags. let's call them... (2 Replies)
Discussion started by: Tobias-Reiper
2 Replies
Email::Date::Format(3pm)				User Contributed Perl Documentation				  Email::Date::Format(3pm)

NAME
Email::Date::Format - produce RFC 2822 date strings SYNOPSIS
use Email::Date::Format qw(email_date); my $header = email_date($date->epoch); Email::Simple->create( header => [ Date => $header, ], body => '...', ); DESCRIPTION
This module provides a simple means for generating an RFC 2822 compliant datetime string. (In case you care, they're not RFC 822 dates, because they use a four digit year, which is not allowed in RFC 822.) FUNCTIONS email_date my $date = email_date; # now my $date = email_date( time - 60*60 ); # one hour ago "email_date" accepts an epoch value, such as the one returned by "time". It returns a string representing the date and time of the input, as specified in RFC 2822. If no input value is provided, the current value of "time" is used. "format_date" is exported only if requested. email_gmdate my $date = email_gmdate; "email_gmdate" is identical to "email_date", but it will return a string indicating the time in Greenwich Mean Time, rather than local time. "format_gmdate" is exported only if requested. PERL EMAIL PROJECT
This module is maintained by the Perl Email Project <http://emailproject.perl.org/wiki/Email::Date::Format> AUTHOR
Ricardo SIGNES, <rjbs@cpan.org>. Adapted from Email::Date, by Casey West. COPYRIGHT
Copyright (c) 2007, Ricarod SIGNES. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.8.8 2007-12-13 Email::Date::Format(3pm)
All times are GMT -4. The time now is 10:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy