Sponsored Content
Full Discussion: awk conditional output
Top Forums Shell Programming and Scripting awk conditional output Post 302931071 by Don Cragun on Saturday 10th of January 2015 12:04:17 AM
Old 01-10-2015
Quote:
Originally Posted by palex
I am confusing everyone... my sincere apologies.
Basically, the string in column #4 is always AS or AOD.

If it is AS, I basically need to write several fields of that line, with one of the fields being "A string of text".

If it is AOD, I basically need to write several fields of that line, with one of the fields being "A different string of text".

I hope that clarifies... sorry again!
We have shown you various ways to process your previous ambiguous requests. Can you use them as a starting point to solve this problem on your own now?

Please show us what you have tried, and if you still can't get it to work, we'll be happy to help you clean up your code so it does what you want it to do.
 

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
BUFFCHAN(8)						      System Manager's Manual						       BUFFCHAN(8)

NAME
buffchan - buffered file-writing backend for InterNetNews SYNOPSIS
buffchan [ -b ] [ -c lines ] [ -C seconds ] [ -d directory ] [ -f fields ] [ -m map ] [ -p pidfile ] [ -l lines ] [ -L seconds ] [ -r ] [ -s file_format ] [ -u ] DESCRIPTION
Buffchan reads lines from standard input and copies certain fields in each line into files named by other fields within the line. Buffchan is intended to be called by innd(8) as an exploder feed. OPTIONS
-b Once buffchan opens a file it keeps it open. The input must therefore never specify more files than can the number of available descriptors can keep open. If the ``-b'' flag is used, the program will allocate a buffer and attach it to the file using set- buf(3). -c If the ``-c'' flag is used with a number n, then buffchan will close, and re-open, a file after every n lines are written to a file. -C Similarly, the ``-C'' flag may be used to specify that all files should be closed and re-opened every n seconds. -d The ``-d'' flag may be used to specify a directory the program should change to before starting. If this flag is used, then the default for the ``-s'' flag is changed to be a simple ``%s.'' -f Buffchan input is interpreted as a set of lines. Each line contains a fixed number of initial fields, followed by a variable number of filename fields. All fields in a line are separated by whitespace. The default number of initial fields is one; the ``-f'' flag may be used to specify a different number of fields. See filechan(8) for an example. -p If the ``-p'' flag is used, the program will write a line containing its process ID (in text) to the specified file. -l If the ``-l'' flag is used with a number n, then buffchan will call fflush(3) after every n lines are written to a file. -L If the ``-L'' flag is used with a number n, then all files will be flushed every n seconds. -r By default, the program sets its standard error to /var/log/news/errlog. To suppress this redirection, use the ``-r'' flag. -s After the initial fields, each remaining field names a file to write. The ``-s'' flag may be used to specify a format string that maps the field to a file name. This is a sprintf(3) format string which should have a single ``%s'' parameter which will be given the field. The default value is /var/spool/news/out.going/%s. See the description of this flag in filechan(8). -u If the ``-u'' flag is used, the program will request unbuffered output. Buffchan can be invoked as an exploder feed (see newsfeeds(5)). As such, if a line starts with an exclamation point it will be treated as a command. There are three commands, described below: flush The ``flush'' command closes and re-opens all open files; ``flush xxx'' which flushes only the specified site. These are analogous to the ctlinnd(8) ``flush'' command, and can be achieved by doing a ``send "flush xxx"'' command. Applications can tell that the ``flush'' has completed by renaming the file before issuing the command; buffchan has completed the command when the original file- name re-appears. Buffchan also changes the access permissions of the file from read-only for everyone to read-write for owner and group as it flushes or closes each output file. It will change the modes back to read-only if it re-opens the same file. drop The ``drop'' command is similar to the ``flush'' command except that any files are not re-opened. If given an argument, then the specified site is dropped, otherwise all sites are dropped. (Note that the site will be restarted if the input stream mentions the site.) When a ctlinnd ``drop site'' command is sent, innd will automatically forward the command to buffchan if the site is a fun- nel that feeds into this exploder. To drop all sites, use the ctlinnd ``send buffchan-site drop'' command. readmap The map file (specified with the ``-m'' flag) is reloaded. HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.11, dated 1996/10/29. SEE ALSO
ctlinnd(8), filechan(8), innd(8), newsfeeds(5). BUFFCHAN(8)
All times are GMT -4. The time now is 05:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy