Sponsored Content
Top Forums Shell Programming and Scripting Awk find in columns with "if then" statement and print results Post 302588376 by charles33 on Sunday 8th of January 2012 08:06:03 PM
Old 01-08-2012
Awk find in columns with "if then" statement and print results

I have a file1.txt

file1.txt
Code:
F-120009210","Felix","U-M-F-F-F-","white","yes","no","U-M-F-F-F-","Bristol","RI","true"
F-120009213","Fluffy","U-F-","white","yes","no","M-F-","Warwick","RI","true"
U-120009217","Lity","U-M-","grey","yes","yes","","Fall River","MA","true"
V-120009218","Pincher","1-1-1-","grey","yes","yes","1-0-","Worcester","MA","true"

Basicly I need to check "column 3 and column 7":
If F- found than Female.
If no F- found check M-, if found than Male
If neither M- or F- found than Unknown

Than print it like result1.txt.

result1.txt
Code:
F-120009210","Felix","U-M-F-F-F-","white","yes","no","U-M-F-F-F-","Bristol","RI","true","Female"
F-120009213","Fluffy","U-F-","white","yes","no","M-F-","Warwick","RI","true","Female"
U-120009217","Lity","U-M-","grey","yes","yes","","Fall River","MA","true","Male"
V-120009218","Pincher","1-1-1-","grey","yes","yes","1-0-","Worcester","MA","true","Unknown"

Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

ls -laR | grep "^-" | awk '{print $9}'| grep "$.txt"

Hi, I don't know hot to make this command work: ls -laR | grep "^-" | awk '{print $9}'| grep "$.txt" It should return the list of file .txt It's important to search .txt at the end of the line, becouse some file name have "txt" in their name but have other extensions (13 Replies)
Discussion started by: DNAx86
13 Replies

3. Shell Programming and Scripting

Results of "find" to an array

I am looking to search a directory for a folder or file and when it finds any hits I want it to store those hits in an array so I can work with those hits later on. I have been trying to do something like this but it isn't putting results into an array like I would like, is it syntax or is this... (8 Replies)
Discussion started by: tret
8 Replies

4. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

5. Shell Programming and Scripting

awk statement to match all lines starting with "#"

Looking for awk statement that will match all lines starting with "# " if ( $1 == \^"#" ) Input file: # of the server. If you would like to set these, please take out the # pound (#) sign in front of one or all severities and set it equal to # severity desired. For example, FATAL=3 #... (2 Replies)
Discussion started by: Arsenalman
2 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

sort, columns, no result! can I print files of "planes"?

hi, please can I ask you for some help? I have data from 3D situation, x y z value I'd like to use gnuplot to generate maps of the value in the planes z=0 to z=1 for example, my file looks like -0,012 0,0060 0,0 0,13972813076023477 -0,012 0,0064319163 4,2894483E-4 ... (1 Reply)
Discussion started by: kocour
1 Replies

8. Shell Programming and Scripting

Why awk print is strange when I set FS = " " instead of FS = "\t"?

Look at the following data file(cou.data) which has four fields separated by tab. Four fields are country name, land area, population, continent where it belongs. As for country name or continent name which has two words, two words are separated by space. (Data are not accurately... (1 Reply)
Discussion started by: chihuyu
1 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

10. UNIX for Beginners Questions & Answers

How to use "awk" to print columns from different files in separate columns?

Hi, I'm trying to copy and paste the sixth column from a bunch of files into a single file having each column pasted in separate columns (and not one after each other in just one column.) I tried this code but works only partially because it copied and pasted 50 rows of each column... (6 Replies)
Discussion started by: Frastra
6 Replies
greylist(1)							Mail Administration						       greylist(1)

NAME
greylist - command line interface to greylistd(8) SYNOPSIS
greylist { -h | --help | help } greylist operation ... DESCRIPTION
This program provides a command line interface to greylistd(8); please refer to that manual page for more information on the purpose and functionality of this program. USAGE
In the following discussion, data... typically refers to the following triplet of information: <sending host's IP address> <sender@address> <recipient@address> The following operations are available: add [--white|--grey|--black] data... Add data to the corresponding list (white if unspecified). If the triplet of a future mail deliveriy (subject to timeouts) matches this data, the idea is that the message would be accepted, temporarily rejected, or permanently rejected, respectively. delete data... Remove data from all lists. If the data exists in any list, the command returns an exit status of 0, otherwise -1. A message is printed on standard output indicating the action taken. check [--white|--grey|--black] data... Check the current status of data, i.e. if a message delivery would succeed if its triplet matched this data. If a list is speci- fied, the word "true" or "false" is printed, indicating whether the data was in the corresponding list; the exit status is also set accordingly. Otherwise, one of the words "white", "grey", and "black" is written on standard output, and the exit status is 0, 1, or 2, respectively. NOTE: This operation is non-intrusive, and thus does not update any of the greylist data. So, for instance, if the data is cur- rently in the "grey" list, but its minimum retry time (retryMin) has elapsed, the text "white" would be printed. However, unless an update takes place prior to the retryMax timeout, the data would still expire from the "grey" list. update [--white|--grey|--black] data... Same, but also update the greylist data accordingly. So if data is currently greylisted, but the minimum retry time retryMin has elapsed since it was first seen, data is moved to the "white" list. This operation would normally be used by mail transport agents (MTAs). stats Print some statistics on greylist utilization and hits. mrtg Print statistics on greylist and whitelist hits in a format that MRTG can use as an External Monitoring Script. list [--white] [--grey] [--black] Print available (original/unhashed) data items from the corresponding list(s). NOTE: Internally, greylistd(8) hashes the provided data into a single 32-bit value for efficiency. Prior to version 0.6, the origi- nal data was not retained; as of version 0.6, data is saved if the "savetriplets" setting in the [data] section of the configuration file is "true". Only data items (i.e. triplets) that have been seen while this setting were enabled can be listed. save Force greylist data to be immediately saved (synchronized) to the filesystem. Data is also saved after any operation if a certain update interval (default is 300 seconds/5 minutes) has elapsed since the last save, and there are no pending requests to greylistd(8). reload Save greylist data to files, then reload configuration and data. clear [--white] [--grey] [--black] Clear all items in the specified list(s), or all lists if none is specified. If the whitelist is cleared, all new data trilplets will initially be in a "grey" state. Use with caution! EXAMPLES
greylist add --white 1.2.3.4 mailinglist@somewhere subscriber@yourhost Whitelists messages received from the IP address 1.2.3.4 on behalf of <mailinglist@somewhere> to <subscriber@yourhost>. greylist check --grey 1.2.3.4 mailinglist@somewhere subscriber@yourhost Prints "true" or "false" on standard output, depending on whether mail received from the IP address 1.2.3.4 on behalf of <mail- inglist@somewhere> to <subscriber@yourhost> should be deferred or not, respectively. The data is neither recorded nor changed to a "white" state. FILES
/var/run/greylistd/socket The UNIX domain socket providing the main interface to "greylistd". AUTHOR
This python script and manual page is written by Tor Slettnes, originally for Debian GNU/Linux. COPYRIGHT
Copyright (C) 2004-2005 Tor Slettnes. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as pub- lished by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. On a Debian GNU/Linux system, the full text of the GPL is available in /usr/share/common-licenses/GPL. It is also available at: http://www.gnu.org/licenses/gpl.html SEE ALSO
greylistd(8) Greylisting daemon. greylistd-setup-exim4(8) Utility to add/remove support for greylistd in Exim 4 configuration files. Tor Slettnes 0.8 greylist(1)
All times are GMT -4. The time now is 07:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy