Sponsored Content
Full Discussion: Quick sed/awk question
Top Forums Shell Programming and Scripting Quick sed/awk question Post 302742173 by lucshi09 on Monday 10th of December 2012 04:50:53 PM
Old 12-10-2012
Quick sed/awk question

Hi fellow linux-ers,

I have a quick question for you. I have the following text, which I would like to modify:

Code:
10 121E(121) 16 Jan
34S 132E 24 Feb
42 176E(176) 18 Sep
21S 164E 25 May
15 171W(-171) 09 Jul

How can I do the following 2 modifications using sed and/or awk?
1. in 1st column, if a field has an "S", delete the "S" and add a "-" in front of number
2. in the 2nd column, delete the parenthesis and the number that exists within it

Thanks!!!
Moderator's Comments:
Mod Comment code tags please
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

a quick SED question

I have a line EXTDIR=`echo $i | sed 's/\-tar.gz//'` which looks for files ending in -tar.gz, i would like to increase the functionality so that it looks for .tar.gz files as well as -tar.gz. Do i put the - in square brackets with a dot ? like this EXTDIR=`echo $i | sed 's/\tar.gz//'` ... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

2. Shell Programming and Scripting

quick sed question

hey, Im just wondering is there away to get sed to read from a variable eg it doesn't seem to work, i really need to be able to recursively change the same data set... (2 Replies)
Discussion started by: vbm
2 Replies

3. Shell Programming and Scripting

Sed or Awk Question

I have some text: 0400-0427 NA Czech Republic R. Prague 5990ca, 6200, 7345 0400-0456 NA, As Romania R. Romania Int'l 6115, 9515, 9690, 11895 0400-0500 NA U. S. A. WYFR 6065, 6855, 9505, 9715 0400-0500 NA,Eu,Af U. S. A. ... (8 Replies)
Discussion started by: petebear
8 Replies

4. Shell Programming and Scripting

Help with AWK -- quick question

Ok. I'm just starting to use AWK and I have a question. Here's what I'm trying to do: uname -n returns the following on my box: ftsdt-svsi20.si.sandbox.com I want to pipe this to an AWK statement and make it only print: svsi20 I tried: uname -n | awk '{ FS = "." ; print $1 }' ... (5 Replies)
Discussion started by: Probos
5 Replies

5. Shell Programming and Scripting

Quick Question on sed command in shell script

Hello, I have the following line in one of my shell scripts. It works fine when the search string($SERACH_STR) exists in the logfile($ALERTLOG) but if the search string does not exist this line errors out at run time. Is there a way to make this line return 0 if it is not able to find the... (4 Replies)
Discussion started by: luft
4 Replies

6. Shell Programming and Scripting

yet another sed/awk question

Unix Guru's , I have a file all_files.txt containing data as follows all_files.txt first file : /a/b/c/file.sh first second CLIENT1 second file : /a/b/c/file.sh first second CLIENT1 first file : /a/b/c/file.sh first second CLIENT2 second file : /a/b/c/file.sh first second... (6 Replies)
Discussion started by: jville
6 Replies

7. Shell Programming and Scripting

Quick Sed Question

Just want to know why when I do the following in sed, the required is not extracted. echo "ab01cde234" | sed 's/*$//' result: ab01cde (Which is correct) echo "ab01cde234" |sed 's/.*\(*\)$/\1/' result: blank (was expecting 234) or echo "ab01cde234" |sed 's/.*\(\)*$/\1/' result: blank... (6 Replies)
Discussion started by: eo29
6 Replies

8. Shell Programming and Scripting

awk Help: quick and easy question may be: How to use &&

Hi Guru's. I am trying to use to check if $5 is greater than 80 & if not 100, then to print $0 : awk '{ if ($5>80) && if ($5 != 100) print $0} But getting error: >bdf1|sed 's/%//g'|awk '{ if ($5>80) && if ($5 != 100) print $0}' syntax error The source line is 1. The error... (6 Replies)
Discussion started by: rveri
6 Replies

9. Shell Programming and Scripting

awk :quick question removing empty line.

How to write in awk to remove lines starting with "#" and then process the file: This is not working: cat file|awk '{if ($0 ~ /^#/) $0="";print NF>0}' When I just give cat file|awk '{if ($0 ~ /^#/) $0="";print }' it prints the blank lines . I don't wnat the blank lines along with the... (15 Replies)
Discussion started by: rveri
15 Replies

10. Shell Programming and Scripting

Quick awk question

gawk 'BEGIN{count=0} /^Jan 5 04:33/,0 && /fail/ && /09x83377/ { count++ } END { print count }' /var/log/syslog what is wrong with this code? i want to search the strings "fail" and "09x83377" from all entries. im grabbing all entries in the log starting from Jan 5 04:33 to the end of the... (3 Replies)
Discussion started by: SkySmart
3 Replies
Net::DNS::Question(3pm) 				User Contributed Perl Documentation				   Net::DNS::Question(3pm)

NAME
Net::DNS::Question - DNS question class SYNOPSIS
"use Net::DNS::Question" DESCRIPTION
A "Net::DNS::Question" object represents a record in the question section of a DNS packet. METHODS
new $question = Net::DNS::Question->new("example.com", "MX", "IN"); Creates a question object from the domain, type, and class passed as arguments. RFC4291 and RFC4632 IP address/prefix notation is supported for queries in in-addr.arpa and ip6.arpa subdomains. parse ($question, $offset) = Net::DNS::Question->parse($data, $offset); Parses a question section record at the specified location within a DNS packet. The first argument is a reference to the packet data. The second argument is the offset within the packet where the question record begins. Returns a Net::DNS::Question object and the offset of the next location in the packet. Parsing is aborted if the question object cannot be created (e.g., corrupt or insufficient data). qname, zname print "qname = ", $question->qname, " "; print "zname = ", $question->zname, " "; Returns the domain name. In dynamic update packets, this field is known as "zname" and refers to the zone name. qtype, ztype print "qtype = ", $question->qtype, " "; print "ztype = ", $question->ztype, " "; Returns the record type. In dymamic update packets, this field is known as "ztype" and refers to the zone type (must be SOA). qclass, zclass print "qclass = ", $question->qclass, " "; print "zclass = ", $question->zclass, " "; Returns the record class. In dynamic update packets, this field is known as "zclass" and refers to the zone's class. print $question->print; Prints the question record on the standard output. string print $qr->string, " "; Returns a string representation of the question record. data $qdata = $question->data($packet, $offset); Returns the question record in binary format suitable for inclusion in a DNS packet. Arguments are a "Net::DNS::Packet" object and the offset within that packet's data where the "Net::DNS::Question" record is to be stored. This information is necessary for using compressed domain names. COPYRIGHT
Copyright (c) 1997-2002 Michael Fuhr. Portions Copyright (c) 2002-2004 Chris Reinhardt. Portions Copyright (c) 2003,2006-2009 Dick Franks. All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl(1), Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Update, Net::DNS::Header, Net::DNS::RR, RFC 1035 Section 4.1.2 perl v5.14.2 2009-12-30 Net::DNS::Question(3pm)
All times are GMT -4. The time now is 09:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy