Sponsored Content
Full Discussion: Combine awk scripts
Top Forums UNIX for Beginners Questions & Answers Combine awk scripts Post 303023549 by RudiC on Wednesday 19th of September 2018 06:46:09 AM
Old 09-19-2018
Would this come near of what you need:
Code:
echo -e "MMS000101S0203430A|20180412E|\nMMB0001INVESTMENT||107-86193-01-03|\nMMB0001FUND||107-86193-04-01|\nMMC9991 " |
awk -F'|' -v OFS=, '
/^MMC9991/      {gsub ("-", "", t)
                 n = split (t, T, OFS)
                 for (i=1; i<n; i++) print rs, T[i]
                }
/^MMS0001/      {rs = substr($1,8) FS substr($2,1,8)
                }
/^MMB0001/      {t = t $3  OFS 
                }
'
01S0203430A|20180412,107861930103
01S0203430A|20180412,107861930401

These 2 Users Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

i want to combine two awk scripts which is having same loop and filelist

hi, to all give me some idea below scripts file=`cat filelist` for filename in $file do awk '{ if ($0 ~ /system/ && flag == 0) { flag=1; print $0; } else if ($0 ~ /system/ && flag == 1) { printf("%s SYSLAY %s %s %s\n",$1,$3, $4, $5); } else print $0; }' $filename >... (6 Replies)
Discussion started by: LAKSHMI NARAYAN
6 Replies

2. UNIX for Dummies Questions & Answers

combine two awk codes

Hello How do I combine the following 2 codes in one, the purpose is to not generate the outfile1 awk '{print $9 "\t" $10 "\t" $11}' infile > outfile1 awk '{ gsub(/.fa/,""); print }' outfile1 > outfile2 Thanks Joseph (2 Replies)
Discussion started by: jdhahbi
2 Replies

3. Shell Programming and Scripting

help with a script that will combine two separate scripts for solaris and aix

Hello experts, I have separate scripts (KSH) each for Solaris and AIX to install core applications (e.g. BigBrother). I also have a script called Installer that gives a menu list to select a particular application to install from a bunch of applications. Now I am trying to combine separate... (7 Replies)
Discussion started by: solaix14
7 Replies

4. Shell Programming and Scripting

Combine awk statements

I have an awk statement that works but I am calling awk twice and I know there has to be a way to combine the two statements into one. The purpose is to pull out just the ip address from loopback1. cat config.txt | nawk 'BEGIN {FS="\n"}{RS="!"}{if ( $0 ~ "interface loopback1" ) print$4}' | nawk... (5 Replies)
Discussion started by: numele
5 Replies

5. Shell Programming and Scripting

how to combine two scripts into one

I need to combine two scripts, into one script. One is to delete something, the to recreate. Here is the scripts: BIN=/usr/lbin LINE='device for 0101a01: lpd://172.25.41.111:515' while read LINE do prt=`echo $LINE | awk '{print $3 }'| cut -c 1-7` echo $prt #drv=`echo $LINE | awk -F":"... (4 Replies)
Discussion started by: ggoliath
4 Replies

6. Shell Programming and Scripting

combine awk and tr -d

Hi Everyone, awk 'BEGIN{print strftime("%c",1272814948)}' | tr -d '\n' how to change tr -d '\n' to be part of the awk? means awk this pchoh time, and awk also remove '\n', instead of using "|" to combine "tr" command. Thanks (2 Replies)
Discussion started by: jimmy_y
2 Replies

7. Shell Programming and Scripting

How to combine two files with awk?

Hi, everyone! I have two files, I want to combine them as follows: File1 AAAA 23 45 AAAB 44 56 AAAC 34 65 AAAD 34 87 File2 AAAA 34 54 AAAE 34 56 Combined file AAAA 23 45 34 54 AAAB 44 56 AAAC 34 65 AAAD 34 87 AAAE 34 56 (13 Replies)
Discussion started by: xshang
13 Replies

8. Shell Programming and Scripting

Combine these two into one liner awk?

ignore the simplicity of the foo file, my actual file is much more hardcore but this should give you the jist of it. need to combine the two awks into one liner. essentially, need to return the value of one particular field in a file that has multiple comma separated fields. thanks guys cat foo... (1 Reply)
Discussion started by: jack.bauer
1 Replies

9. Shell Programming and Scripting

Combine columns - awk

Need some help with this ... please 60644,NJ090237_0263_GRP,NJ090237_0263_VIEW,NJ090237_0263_PSGRP,NJ090237_0263_GOLD_CSGRP,,06E:0_08E:0_09E:0_11E:0,0CE5,TDEV,34,VP_TIER... (3 Replies)
Discussion started by: greycells
3 Replies

10. Shell Programming and Scripting

Combine awk commands into one

my code: gawk 'NR>'"${LASTLINENUM}"' && NR<='"${LINEENDNUM}"'' ${LOGFILE} | gawk '{l=$0;} /'"${STRING1}"'/ && /'"${STRING2}"'/ {for (i=NR-'"${BEFOREGLAF}"'; i<=NR+'"${AFTERGLAF}"'; i++) o=i; t++;} END { for(i=1; i<=NR; i++) if (o) print l; print t+=0;}' i would like to combine this into one... (5 Replies)
Discussion started by: SkySmart
5 Replies
PPP(1)							      General Commands Manual							    PPP(1)

NAME
pppclient, pppserver - point to point protocol SYNOPSIS
pppclient [ -d ][ -b baudrate ][ -i myipaddr ][ -p peeripaddr ][ dialdevice ] pppserver [ -d ] ndev myipaddr firstipaddr firstdev [ baud0 baud1 ... ] DESCRIPTION
The Point to Point Protocol is used to encapsulate Internet Protocol packets for transfer over serial lines or other protocol connections. Pppclient makes a connection to a PPP server and passes IP packets over the connection. If dialdevice is omitted, standard input and out- put are used as the connection. If dialdevice begins with a slash, pppclient assumes it is a file name, open(2)'s it, and uses the result as the connection. Otherwise, dialdevice is passed as the destination address to dial(2) to set up the connection. If the connection is successful, pppclient creates a pipe, pushes the IP line discipline onto it, and sets the local and remote addresses of the IP interface to myipaddr and peeripaddr. It then loops transferring packets between the pipe and the connection. If either myi- paddr or peeripaddr is omitted, pppclient requests them from the server. The options are d print debugging information. b baud rate of the serial line. p peer ip address (in case the peer asks for its ip address over IPCP). i the local ip address to be established for this connection. Pppserver treats serial lines as PPP connections, switching packets between them and the local machine. It creates a pipe for a local IP interface (address myipaddr), opens a set of serial lines, and switches packets between the local interface and the serial lines. Ndev specifies the number of serial devices to serve. The devices are named /dev/eia{firstdev} through /dev/eia{firstdev+ndev-1}. Their remote IP addresses are firstipaddr through firstipaddr+ndev-1. The default baud rate is 9600. If any arguments follow firstdev (baud0, baud1, ...), they are used as baud rates for the serial lines. The only option, -d, turns on debugging output. Both pppclient and pppserver accept all options defined in RFCs 1331 and 1332. EXAMPLES
Start up a server for serial lines /dev/eia[2-6] with remote IP addresses 131.107.1.100 through 131.107.1.103 and baud rates of 19200, 2400, 9600, 9600. The local IP address is 131.107.1.1. pppserver 4 131.107.1.1 131.107.1.100 2 19200 2400 SOURCE
/sys/src/cmd/ppp PPP(1)
All times are GMT -4. The time now is 07:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy