Sponsored Content
Top Forums Shell Programming and Scripting Need help in solving to obtain desired print output using awk or perl or any commands, Please help!! Post 302944346 by deepKrish on Tuesday 19th of May 2015 01:47:36 AM
Old 05-19-2015
Need help in solving to obtain desired print output using awk or perl or any commands, Please help!!

I have an file which have data in lines as follows

Code:
ad, findline=24,an=54,ab=34,av=64,ab=7989,ab65=34,aj=323,ay=34,au=545,ad=5545
ab,abc,an10=23,an2=24,an31=32,findline=00,an33=23,an32=26,an40=45,ac23=5,ac=87,al=76,ad=26
ab,abc,an1=23,ar=57,an10=24,findline=00,at=39,am=67,an31=35,an33=23,an3=26,an40=95,ac=55

I want to obtain output as below

Code:
findline=00 an10=23 an31=32 an40=45
findline=00 an10=24 an31=32 an40=95


i have been using the below commands before, with the below output

Code:
gzip -dcr/file path/filename.gz | grep findline=00 | awk -F, '{print $1,$4,$6,$7}' | sort -n | uniq -c


OUTPUT
======
Code:
1 findline=00 an10=23 an31=32 an40=45
1 findline=00 an10=24 an31=32 an40=95


INPUT File Lines (eg)
Code:
findline=02,ab,abc,an19=23,an1=28,an31=36,an40=41,an33=22,an32=28,ac23=53,am=57,al33=56,an3=56
findline=04,ab,abc,an14=24,an1=27,an31=334,an40=98,ar33=59,an32=22,ac23=19,am=17,al33=13,an3=76,ac=55
findline=00,ab,abc,an10=23,an1=24,an31=32,an40=45,an33=23,an32=26,ac23=5,am=87,al33=76,an3=16
findline=00,ab,abc,an10=24,an1=23,an31=35,an40=95,ar33=57,an32=24,ac23=39,am=67,al33=23,an3=26,ac=55


But since my variable that I am looking out for an10, an31 and an40 are in different fields, in the new files, I cant obtain an uniform output with the above command.
Any idea how to get the desired output using the desired command

Last edited by Don Cragun; 05-19-2015 at 03:48 AM.. Reason: Add CODE and ICODE tags again.
 

10 More Discussions You Might Find Interesting

1. Solaris

how can obtain other user commands on the same server.

hi buddies, i want to learn something,so that we have several users on a sun server and via telnet, we are connecting to server same username and password root/something as root and after connection i want to see what other roots or users are doing on the server, i want to see their command.... (2 Replies)
Discussion started by: nibiru78
2 Replies

2. Shell Programming and Scripting

Lay person needs perl help solving error message

Hi, My name is Tex I am past 60 and in need of perl help. My hobby is genealogy and I am using a perl program to display my data on my web pages. I don't even know enough to know how to ask in the right way for the help I need. This program is written in perl it is open and has been updated... (2 Replies)
Discussion started by: tex
2 Replies

3. Shell Programming and Scripting

using perl or awk to print output

suppose u have file File A A -> G C->D A -> R P->A File B A=1 C=2 D=3 E=4 F=5 G=6 H=7 I=8 K=9 L=10 M=11 (5 Replies)
Discussion started by: cdfd123
5 Replies

4. Shell Programming and Scripting

awk syntax mistake doubles desired output

I am trying to add a line to a BASH shell script to print out a large variable length table on a web page. I am very new to this obviously, but I tried this with awk and it prints out every line twice. What I am doing wrong? echo "1^2^3%4^5^6%7^8^9%" | awk 'BEGIN { RS="%"; FS="^"; } {for (i =... (6 Replies)
Discussion started by: awknewb123
6 Replies

5. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

6. Shell Programming and Scripting

How to grep the desired output and output to a file?

currently I have process from a raw file to this stage ALTER TABLE "EXCEL_ADMIN"."TC_TXN_VOID" ADD CONSTRAINT "PK_TC_TXN_VOID" PRIMARY KEY ("TC_TXN_IID") ALTER TABLE "EXCEL_ADMIN"."TC_TXN_AMT" ADD CONSTRAINT "PK_TC_TXN_AMT" PRIMARY KEY ("TC_TXN_AMT_IID") ALTER TABLE... (10 Replies)
Discussion started by: jediwannabe
10 Replies

7. Shell Programming and Scripting

Unable to obtain the desired output

Hi, I am unable to get beyond the exit function. The shell script is used to look for masked files and copy paste them to another location. Please refer to the code below for more information. Thanks Brinjit #!/usr/bin/ksh... (10 Replies)
Discussion started by: brinjit
10 Replies

8. Shell Programming and Scripting

Print Value between desired html tag

Hi, I have a html line as below :-... (6 Replies)
Discussion started by: satishmallidi
6 Replies

9. Shell Programming and Scripting

Print if found non-desired result

I have a result like this root@server # grep -rl maldet /etc/cron* /etc/cron.d/maldet_daily /etc/cron.d/malcron /etc/cron.d/malcrondaily /etc/cron.d/malcronweekly What I need is, I need an if/else condition such that, if there is any output other than /etc/cron.d/maldet_daily in the... (8 Replies)
Discussion started by: anil510
8 Replies

10. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 05:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy