Sponsored Content
Full Discussion: awk conditional output
Top Forums Shell Programming and Scripting awk conditional output Post 302931050 by Don Cragun on Friday 9th of January 2015 07:08:09 PM
Old 01-09-2015
How about giving us an English description of what is supposed to happen? How about giving us an English description of the contents of the input file?

Is the input sorted in reverse order on field 4?

Is the string Text literal, or is there some table of output text strings to be produced?

Is the number after Text supposed to toggle between 1 and 2 every time the content of field 4 changes? Or, is some other algorithm to be used?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK - conditional cause

Hello guys, I want to make a conditional cause in the following file using awk: awk '{ if ($2 != 0) print $1, $2, $3}' test.csv > test2.csv FILE EXAMPLE = test.csv string,number,date abc,0,20050101 def,1,20060101 ghi,2,20040101 jkl,12,20090101 mno,123,20020101 ... (2 Replies)
Discussion started by: Rafael.Buria
2 Replies

2. Shell Programming and Scripting

Awk Conditional

Hi Guys, i have this files: xyz20080716.log opqrs20080716.log abcdef20080716.log xyz20080717.log oprs20080717.log abcde20080717.log currentdate: 20080717.log I want to make script to zip the file for past day. Can anyone help for this? i've just learn awk scripting & still confused with... (3 Replies)
Discussion started by: icy_blu_blu
3 Replies

3. Shell Programming and Scripting

AWK conditional addition

I have a column of numbers $2, I would like to add 360 to all numbers that are negative. This method seems a bit convoluted, and does not work (outputs 0): BEGIN { A=sprintf("%d", $2); if(A<0) A=A+360; BIN++; } END { for(A in BIN) print... (5 Replies)
Discussion started by: chrisjorg
5 Replies

4. Shell Programming and Scripting

awk conditional find

Hi, I have a file in the following format: aabbba 25.31806899 baaabb 38.21808852 cccccu 1.31819523 552258121.31818253 ffddybb 5.41815555 almcamc87561812689 223aqas5.661828345 adacaaaaaaa1821285 adacaaaaaaa1821286 smckaa 3.81828756 ada2512510c1821287 ada2522511c1821328... (4 Replies)
Discussion started by: alex2005
4 Replies

5. Shell Programming and Scripting

Conditional awk

Hello All, I have a file like this: bash-3.00$ cat 1.txt 201112091147|0|1359331220|1025 201112091147|0|1359331088|1024 201112091144|0|1359331172|1025 201112091147|0|1359331220|1021 201112091149|0|1359331088|1027 201112091144|0|1359331172|1029 and a list of MSISDNs in another file... (9 Replies)
Discussion started by: EAGL€
9 Replies

6. Shell Programming and Scripting

Help with conditional clauses for script output

Hello. I am new this site as well as new to shell scripting and this is my first form... Please help me with the following shell script. I am executing a shell script to run every 15 min (scheduled in cronjob) and it gives an output in an output file which is e-mailed. CONCCOUNT=`cat... (1 Reply)
Discussion started by: Jamessteevens
1 Replies

7. Shell Programming and Scripting

awk - read from a file and write conditional output

I have a file, which has '|' as separator; I need to read each line from that file and produce output to another file. While reading, I have certain condition on few specific columns (like column3 ='good'); only those lines will be processed. (3 Replies)
Discussion started by: mady135
3 Replies

8. Shell Programming and Scripting

Conditional output redirection

Hi there, I'm in a coding mood! I've come through many ways of conditionally redirect the output of a script like: ] || exec &> /dev/nullBut my goal is slightly different. I would like to conditionally redirect the output of a command depending on the status of the command itself: if !... (6 Replies)
Discussion started by: chebarbudo
6 Replies

9. Shell Programming and Scripting

Sending sql output to email body with conditional subject line

hi , i have written below piece of code to meet the requirement but i am stuck in the logic here. the requirement are: 1) to send the sql out put to email body with proper formatting. 2) if count_matching = Yes then mail should triggered with the subject line ... (10 Replies)
Discussion started by: itzkashi
10 Replies

10. Shell Programming and Scripting

Multi-conditional IF - awk

I have a 6 column array with 2 million rows that looks like this: 1 1089699 rs6686003 G A g 1 1090557 rs7553429 A C c 1 1094738 rs4970362 A G a 1 1099342 rs9660710 A C c 1 1106473 rs4970420 G A a 1 1108637 rs4970421 G A g 1 1119858 rs1320565 C T c 1... (5 Replies)
Discussion started by: Geneanalyst
5 Replies
Text::Soundex(3pm)					 Perl Programmers Reference Guide					Text::Soundex(3pm)

NAME
Text::Soundex - Implementation of the soundex algorithm. SYNOPSIS
use Text::Soundex; # Original algorithm. $code = soundex($name); # Get the soundex code for a name. @codes = soundex(@names); # Get the list of codes for a list of names. # American Soundex variant (NARA) - Used for US census data. $code = soundex_nara($name); # Get the soundex code for a name. @codes = soundex_nara(@names); # Get the list of codes for a list of names. # Redefine the value that soundex() will return if the input string # contains no identifiable sounds within it. $Text::Soundex::nocode = 'Z000'; DESCRIPTION
Soundex is a phonetic algorithm for indexing names by sound, as pronounced in English. The goal is for names with the same pronunciation to be encoded to the same representation so that they can be matched despite minor differences in spelling. Soundex is the most widely known of all phonetic algorithms and is often used (incorrectly) as a synonym for "phonetic algorithm". Improvements to Soundex are the basis for many modern phonetic algorithms. (Wikipedia, 2007) This module implements the original soundex algorithm developed by Robert Russell and Margaret Odell, patented in 1918 and 1922, as well as a variation called "American Soundex" used for US census data, and current maintained by the National Archives and Records Administration (NARA). The soundex algorithm may be recognized from Donald Knuth's The Art of Computer Programming. The algorithm described by Knuth is the NARA algorithm. The value returned for strings which have no soundex encoding is defined using $Text::Soundex::nocode. The default value is "undef", however values such as 'Z000' are commonly used alternatives. For backward compatibility with older versions of this module the $Text::Soundex::nocode is exported into the caller's namespace as $soundex_nocode. In scalar context, "soundex()" returns the soundex code of its first argument. In list context, a list is returned in which each element is the soundex code for the corresponding argument passed to "soundex()". For example, the following code assigns @codes the value "('M200', 'S320')": @codes = soundex qw(Mike Stok); To use "Text::Soundex" to generate codes that can be used to search one of the publically available US Censuses, a variant of the soundex algorithm must be used: use Text::Soundex; $code = soundex_nara($name); An example of where these algorithm differ follows: use Text::Soundex; print soundex("Ashcraft"), " "; # prints: A226 print soundex_nara("Ashcraft"), " "; # prints: A261 EXAMPLES
Donald Knuth's examples of names and the soundex codes they map to are listed below: Euler, Ellery -> E460 Gauss, Ghosh -> G200 Hilbert, Heilbronn -> H416 Knuth, Kant -> K530 Lloyd, Ladd -> L300 Lukasiewicz, Lissajous -> L222 so: $code = soundex 'Knuth'; # $code contains 'K530' @list = soundex qw(Lloyd Gauss); # @list contains 'L300', 'G200' LIMITATIONS
As the soundex algorithm was originally used a long time ago in the US it considers only the English alphabet and pronunciation. In particular, non-ASCII characters will be ignored. The recommended method of dealing with characters that have accents, or other unicode characters, is to use the Text::Unidecode module available from CPAN. Either use the module explicitly: use Text::Soundex; use Text::Unidecode; print soundex(unidecode("FranxE7ais")), " "; # Prints "F652 " Or use the convenient wrapper routine: use Text::Soundex 'soundex_unicode'; print soundex_unicode("FranxE7ais"), " "; # Prints "F652 " Since the soundex algorithm maps a large space (strings of arbitrary length) onto a small space (single letter plus 3 digits) no inference can be made about the similarity of two strings which end up with the same soundex code. For example, both "Hilbert" and "Heilbronn" end up with a soundex code of "H416". MAINTAINER
This module is currently maintain by Mark Mielke ("mark@mielke.cc"). HISTORY
Version 3 is a significant update to provide support for versions of Perl later than Perl 5.004. Specifically, the XS version of the soundex() subroutine understands strings that are encoded using UTF-8 (unicode strings). Version 2 of this module was a re-write by Mark Mielke ("mark@mielke.cc") to improve the speed of the subroutines. The XS version of the soundex() subroutine was introduced in 2.00. Version 1 of this module was written by Mike Stok ("mike@stok.co.uk") and was included into the Perl core library set. Dave Carlsen ("dcarlsen@csranet.com") made the request for the NARA algorithm to be included. The NARA soundex page can be viewed at: "http://www.nara.gov/genealogy/soundex/soundex.html" Ian Phillips ("ian@pipex.net") and Rich Pinder ("rpinder@hsc.usc.edu") supplied ideas and spotted mistakes for v1.x. perl v5.16.2 2012-08-26 Text::Soundex(3pm)
All times are GMT -4. The time now is 06:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy