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
DateTime::Locale::en_BE(3)				User Contributed Perl Documentation				DateTime::Locale::en_BE(3)

NAME
DateTime::Locale::en_BE SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'en_BE' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for English Belgium. DATA
This locale inherits from the DateTime::Locale::en locale. It contains the following data. Days Wide (format) Monday Tuesday Wednesday Thursday Friday Saturday Sunday Abbreviated (format) Mon Tue Wed Thu Fri Sat Sun Narrow (format) M T W T F S S Wide (stand-alone) Monday Tuesday Wednesday Thursday Friday Saturday Sunday Abbreviated (stand-alone) Mon Tue Wed Thu Fri Sat Sun Narrow (stand-alone) M T W T F S S Months Wide (format) January February March April May June July August September October November December Abbreviated (format) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Narrow (format) J F M A M J J A S O N D Wide (stand-alone) January February March April May June July August September October November December Abbreviated (stand-alone) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Narrow (stand-alone) J F M A M J J A S O N D Quarters Wide (format) 1st quarter 2nd quarter 3rd quarter 4th quarter Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) 1st quarter 2nd quarter 3rd quarter 4th quarter Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide Before Christ Anno Domini Abbreviated BC AD Narrow B A Date Formats Full 2008-02-05T18:30:30 = Tuesday 5 February 2008 1995-12-22T09:05:02 = Friday 22 December 1995 -0010-09-15T04:44:23 = Saturday 15 September -10 Long 2008-02-05T18:30:30 = 5 Feb 2008 1995-12-22T09:05:02 = 22 Dec 1995 -0010-09-15T04:44:23 = 15 Sep -10 Medium 2008-02-05T18:30:30 = 05 Feb 2008 1995-12-22T09:05:02 = 22 Dec 1995 -0010-09-15T04:44:23 = 15 Sep -10 Short 2008-02-05T18:30:30 = 05/02/08 1995-12-22T09:05:02 = 22/12/95 -0010-09-15T04:44:23 = 15/09/-10 Default 2008-02-05T18:30:30 = 05 Feb 2008 1995-12-22T09:05:02 = 22 Dec 1995 -0010-09-15T04:44:23 = 15 Sep -10 Time Formats Full 2008-02-05T18:30:30 = 18 h 30 min 30 s UTC 1995-12-22T09:05:02 = 09 h 05 min 02 s UTC -0010-09-15T04:44:23 = 04 h 44 min 23 s UTC Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Datetime Formats Full 2008-02-05T18:30:30 = Tuesday 5 February 2008 18 h 30 min 30 s UTC 1995-12-22T09:05:02 = Friday 22 December 1995 09 h 05 min 02 s UTC -0010-09-15T04:44:23 = Saturday 15 September -10 04 h 44 min 23 s UTC Long 2008-02-05T18:30:30 = 5 Feb 2008 18:30:30 UTC 1995-12-22T09:05:02 = 22 Dec 1995 09:05:02 UTC -0010-09-15T04:44:23 = 15 Sep -10 04:44:23 UTC Medium 2008-02-05T18:30:30 = 05 Feb 2008 18:30:30 1995-12-22T09:05:02 = 22 Dec 1995 09:05:02 -0010-09-15T04:44:23 = 15 Sep -10 04:44:23 Short 2008-02-05T18:30:30 = 05/02/08 18:30 1995-12-22T09:05:02 = 22/12/95 09:05 -0010-09-15T04:44:23 = 15/09/-10 04:44 Default 2008-02-05T18:30:30 = 05 Feb 2008 18:30:30 1995-12-22T09:05:02 = 22 Dec 1995 09:05:02 -0010-09-15T04:44:23 = 15 Sep -10 04:44:23 Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 Tue 1995-12-22T09:05:02 = 22 Fri -0010-09-15T04:44:23 = 15 Sat Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 PM 1995-12-22T09:05:02 = 9:05 AM -0010-09-15T04:44:23 = 4:44 AM Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 PM 1995-12-22T09:05:02 = 9:05:02 AM -0010-09-15T04:44:23 = 4:44:23 AM M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M/d) 2008-02-05T18:30:30 = 2/5 1995-12-22T09:05:02 = 12/22 -0010-09-15T04:44:23 = 9/15 MEd (E, M/d) 2008-02-05T18:30:30 = Tue, 2/5 1995-12-22T09:05:02 = Fri, 12/22 -0010-09-15T04:44:23 = Sat, 9/15 MMdd (dd/MM) 2008-02-05T18:30:30 = 05/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 MMM (LLL) 2008-02-05T18:30:30 = Feb 1995-12-22T09:05:02 = Dec -0010-09-15T04:44:23 = Sep MMMd (MMM d) 2008-02-05T18:30:30 = Feb 5 1995-12-22T09:05:02 = Dec 22 -0010-09-15T04:44:23 = Sep 15 MMMEd (E, MMM d) 2008-02-05T18:30:30 = Tue, Feb 5 1995-12-22T09:05:02 = Fri, Dec 22 -0010-09-15T04:44:23 = Sat, Sep 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = February 5 1995-12-22T09:05:02 = December 22 -0010-09-15T04:44:23 = September 15 MMMMEd (E, MMMM d) 2008-02-05T18:30:30 = Tue, February 5 1995-12-22T09:05:02 = Fri, December 22 -0010-09-15T04:44:23 = Sat, September 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (M/yyyy) 2008-02-05T18:30:30 = 2/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 9/-010 yMEd (EEE, M/d/yyyy) 2008-02-05T18:30:30 = Tue, 2/5/2008 1995-12-22T09:05:02 = Fri, 12/22/1995 -0010-09-15T04:44:23 = Sat, 9/15/-010 yMMM (MMM y) 2008-02-05T18:30:30 = Feb 2008 1995-12-22T09:05:02 = Dec 1995 -0010-09-15T04:44:23 = Sep -10 yMMMEd (EEE, MMM d, y) 2008-02-05T18:30:30 = Tue, Feb 5, 2008 1995-12-22T09:05:02 = Fri, Dec 22, 1995 -0010-09-15T04:44:23 = Sat, Sep 15, -10 yMMMM (MMMM y) 2008-02-05T18:30:30 = February 2008 1995-12-22T09:05:02 = December 1995 -0010-09-15T04:44:23 = September -10 yQ (Q yyyy) 2008-02-05T18:30:30 = 1 2008 1995-12-22T09:05:02 = 4 1995 -0010-09-15T04:44:23 = 3 -010 yQQQ (QQQ y) 2008-02-05T18:30:30 = Q1 2008 1995-12-22T09:05:02 = Q4 1995 -0010-09-15T04:44:23 = Q3 -10 Miscellaneous Prefers 24 hour time? Yes Local first day of the week Monday SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.16.2 2013-08-25 DateTime::Locale::en_BE(3)
All times are GMT -4. The time now is 02:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy