Sponsored Content
Full Discussion: Using quotes in awk
Top Forums Shell Programming and Scripting Using quotes in awk Post 302976172 by Don Cragun on Friday 24th of June 2016 01:59:30 PM
Old 06-24-2016
It is not restricted to AIX. The standards explicitly state that the input Record Separator is the 1st character or the string assigned to RS and the results are unspecified if the string assigned to RS contains more than one character. Some implementations of awk allow using an ERE in RS (which is required by the standards for FS, but not for RS). The behavior you are seeing on AIX is common for most implementations of awk on UNIX and BSD systems. Most, if not all, Linux systems support the extension that allows RS to be set to an ERE.

With a standards-conforming awk:
Code:
awk '
c == 0 {
	f1 = $0
	c = 1
	next
}
c == 1 {
	print f1 $0
	c = 2
}
NF == 0 {
	c = 0
}' file1

should do what you want.

If someone wants to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem with quotes in awk script

i have write this script: #!/usr/bin/gawk -f BEGIN { strins="/usr/bin/mysql --user=user --password=pass -h localhost -D admin_test -e 'INSERT INTO test (id, perc) VALUES ('aaa',0)'" system(strins) } the table test are so defined: id(varchar(10)), perc(int(10)) the error that i... (10 Replies)
Discussion started by: dogo21sob
10 Replies

2. Shell Programming and Scripting

quotes using awk

i want to print the statement below using awk,but i am unable to get the quotes ("22345",1,"Thank you"); How can i do this (5 Replies)
Discussion started by: tomjones
5 Replies

3. UNIX for Advanced & Expert Users

awk function in handling quotes

Hi all, I have input lines like below empno,ename,sal,description ---------------------------- 311,"jone,abc",2000,manager 301,david,200,"president,ac" I need to sum the salary of them i.e. 2000+200 anything suggested Thanks, Shahnaz. Use code tags. (5 Replies)
Discussion started by: shahnazurs
5 Replies

4. Shell Programming and Scripting

Using double quotes in awk

Hi I read somewhere that when using double quotes in awk; variables gets expanded else it doesn't. So I tried to use the double quotes inside an awk statement as below: from_instance_trans=`awk "/INPUT =\"$frm_inst\"/,/<\/TRANSFORMATION>/" $xml_object | grep -w "<TRANSFIELD" | awk... (9 Replies)
Discussion started by: dips_ag
9 Replies

5. UNIX for Dummies Questions & Answers

Help populating double quotes using awk

Want to populate double quotes for each filed using awk: Input: cat file.txt => "1-23-test_test1-test2" Required output : "1-23-test_test1-test2"|"#GT_properties_xyz" Was trying the below command on solaris 9 machine : awk -F"|" '{print $1"|""#GT_properties_xyz"}' file.txt ... (8 Replies)
Discussion started by: rajachandhok
8 Replies

6. Shell Programming and Scripting

awk without quotes

I want to execute awk command without quotes. who am i | awk {'print $2'} above code should be something like: who am i | awk {print $2} Why such weird requirement? Im assigning command to a variable, hence i need to escape the quotes. e.g: x='who am i | awk {\'print $2\'}' I want... (11 Replies)
Discussion started by: Arun_Linux
11 Replies

7. Shell Programming and Scripting

awk problem with quotes

can someone help me with this. i keep getting errors: var1="MaxClients" var2="java|could not.*problem found|panic() failure seen|aborting " awk 'NR>=1&&NR<=10 && /'${var1}'/ && !/'${var2}'/ {++c}c==3{o=$0 RS $0 RS $0; print o; c=0}' log when i run the above, i keep getting: awk:... (3 Replies)
Discussion started by: SkySmart
3 Replies

8. Shell Programming and Scripting

awk - Print where value is in quotes

Hi All, I have input data like follows: "1234"|"ABC" "1234"|"CBA" "1222"|"ZZZ" I am trying to awk print all records where Col1 = "1234". Below is the code I have so far: Var1=1 Var2=1234 awk -F "|" "$ ${Var1} == "\"${Var2}\"" { print; }' inputfile However when the AWK... (2 Replies)
Discussion started by: RichZR
2 Replies

9. UNIX for Beginners Questions & Answers

Please explain the use of quotes in awk command in below example-

Example: `abc.ksh | grep '^GLIS'| awk -F' ' '{print \$1}'`; (3 Replies)
Discussion started by: Tanu
3 Replies

10. Shell Programming and Scripting

awk -File contain double quotes

Hi ALL, file data like : test.csv a,b,"c,d" my awk version is 4.0.2 ,if i am using the below code is working fine. awk -vFPAT='(*)|("+")' -vOFS="," '{print $3}' test.csv if the awk version is 3.1.7 is not working . Could you please help me on this one. output should be : "c,d" (6 Replies)
Discussion started by: bmk123
6 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 05:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy