Sponsored Content
Full Discussion: awk regex- include text
Top Forums Shell Programming and Scripting awk regex- include text Post 302652927 by jamie_123 on Friday 8th of June 2012 05:56:38 AM
Old 06-08-2012
awk regex- include text

Hi

I am trying to filter some data using awk. I have a statement-
Code:
 awk 'BEGIN { FS = "\n" ; RS = "" } { if ( $6 = "City: " ) { print "City: Unknown" } else { print $6 } }'`

The $6 values are
Code:
City: London
City: Madrid
City: 
City: Tokyo

This expression seems to catch all the lines as satisfying the if statement, but I want it to catch only the City: line. How do I put a regex for that here?

Thanks!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to include 'date' in my awk?

Hi, I have problem in including date in side awk, my code as follows: performace=performace.txt reporttime=`date` cat $performace | grep "testString" | awk '{ if ($3 > 20 ){print $reporttime $1 $2 $3}}' >> $rpt $reporttime is not reflecting properly in my report file($rpt)? how to... (3 Replies)
Discussion started by: redlotus72
3 Replies

2. Shell Programming and Scripting

Include Line Before Pattern Using Sed / Awk

Hi, I have a sql file that runs something like this vi Test.sql REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM PUBLIC; REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM DEMO_READ; REVOKE SELECT ON DEMO_USER.DEMO_NOMINEE_TEST FROM DEMO_READ; REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM... (3 Replies)
Discussion started by: rajan_san
3 Replies

3. Shell Programming and Scripting

Problem with sending email(to include contents of text file)

Hello, I was using a shell script for sending contents of a text file(email.report) to different users. I was using the below command in my script to send email... cat email.report | /usr/bin/mailx -s $REQ_SUBJECT -h 5 abc@xyz.com It was working fine all these days but now all of a sudden it... (18 Replies)
Discussion started by: smarty86
18 Replies

4. Shell Programming and Scripting

Selecting a part of the text (regex pattern, awk, sed)

Hello, let's start by giving you guys a few examples of the text: "READ /TEXT123/ABC123" "READ /TEXT123/ABC123/" "READ TEXT123/ABC123" "READ TEXT123/ABC123/" "READ TEXT123/TEXT456/ABC123" "READ /TEXT123/TEXT456/ABC123" "READ /TEXT123/TEXT456/ABC123/" TEXT and ABC can be and I... (5 Replies)
Discussion started by: TehOne
5 Replies

5. Shell Programming and Scripting

Need to include two more columns in the file using awk

Hi, I have a input file with many records as below: 1J4RR4GG0BC508200 68646 1 N M i want my output file to be like with columns included dgismdh and timestamp : Example: 1J4RR4GG0BC508200 68646 1 N M dgismdh 2012-02-21 07:22:25.98591 How to do it.can we do using awk? Pls help. (6 Replies)
Discussion started by: sonam273
6 Replies

6. Shell Programming and Scripting

how to include a text pattern in system function in PERL

Pleeeeease help.. I'm working in perl i have a system function to check whether a file is readable for others or not. i just want to print a text in that command my command is : system ("ls -la $filename | awk '\$1~ /^-......r../ {print \$9}'"); i know for displaying text in awk... (6 Replies)
Discussion started by: shubhamsachdeva
6 Replies

7. Shell Programming and Scripting

Include information in certain columns using grep and awk

HI all, I have data in a file that looks like this: 1 HOW _ NNP NNP _ 3 nn _ _ 2 DRUGS _ NNP NNP _ 3 nn _ _ 3 ACT _ NNP NNP _ 0 null _ _ 4 : _ ... (3 Replies)
Discussion started by: owwow14
3 Replies

8. Shell Programming and Scripting

Regex to include up to blank line.

Hi guys I am trying to figure out how to match a pattern with a regex up to a full blank line. I will show you what I mean with this example: example A movie name: ted movie name: TMNT movie name: Jinxed example B movie names: Gravity Faster Turbo song titles: dont hello problem (8 Replies)
Discussion started by: acoding
8 Replies

9. Shell Programming and Scripting

Include pathname in awk output?

I am running an awk to verify all the memory settings for tomcat, and need to include path or directory in output .... I am running: awk '{ print $3 }' /opt/dir1/dir2/*/tomcat/bin/setenv.sh Output results: -Xms1024m -Xmx1536m -Xmx1536m -Xmx1024m -Xms1024m -Xms1024m -Xms512m -Xms1024m... (3 Replies)
Discussion started by: kgolli
3 Replies

10. Shell Programming and Scripting

awk to parse field and include the text of 1 pipe in field 4

I am trying to parse the input in awk to include the |gc= in $4 but am not able to. The below is close: awk so far: awk '{sub(/\|]+]++/, ""); print }' input.txt Input chr1 955543 955763 AGRN-6|pr=2|gc=75 0 + chr1 957571 957852 AGRN-7|pr=3|gc=61.2 0 + chr1 970621 ... (7 Replies)
Discussion started by: cmccabe
7 Replies
SKY(6)								   Games Manual 							    SKY(6)

NAME
sky - science fiction adventure game DESCRIPTION
A science-fiction thriller set in a bleak post-apocalyptic vision of the future, Beneath a Steel Sky revolves around "Union City", where selfishness, rivalry, and corruption by its citizens seems to be all too common, those who can afford it live underground, away from the pollution and social problems which are plaguing the city. You take on the role of Robert Foster, an outcast of sorts from the city since a boy who was raised in a remote environment outside of Union City simply termed "the gap". Robert's mother took him away from Union City as a child on their way to "Hobart" but the helicopter crashed on its way, unfortunately Robert's mother dies, but he survives and is left to be raised by a local tribe from the gap. Years later, Union City security drops by and abducts Robert, killing his tribe in the process; upon reaching the city the helicopter tak- ing him there crashes with him escaping, high upon a tower block in the middle of the city he sets out to discover the truth about his past, and to seek vengeance for the killing of his tribe. OPTIONS
--help Display help for the command --version Display version and author information HISTORY
Jul 10 2004: First version of this manual page. AUTHOR
This manual page was written by Tore Anderson <tore@debian.org> for the Debian GNU system (but may be used by others). Tore Anderson Jul 10, 2004 SKY(6)
All times are GMT -4. The time now is 03:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy