Sponsored Content
Top Forums Shell Programming and Scripting Explanation of print statement - awk Post 302764751 by Corona688 on Thursday 31st of January 2013 10:46:10 PM
Old 01-31-2013
I can see why you're puzzled, that took some thought.

Nothing at all is assigned to X. It's printing a newline. print "" would have the same effect, but they saved one character by using a blank variable. Just print all by itself with no parameters would print the entire line, not what you want.

The printf statements do not print newlines, those must be explicit when using printf. So it prints a bunch of things into one long line, then uses print "" to finish off the line.

Are you sure that's OFS,$i and not OFS $i ? Two things into a single %s is a syntax error as far as I know.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK explanation

Hi, Could anyone please explain why we have arr=1 - what does this statement do? awk -F\; 'FNR==NR{arr=1;next};$3 in arr' core.txt gmrd.txt Any help appreciated (2 Replies)
Discussion started by: penfold
2 Replies

2. Shell Programming and Scripting

Print to 2 files in awk if statement

Hi all, I have some code like this awk -F, '{ if ($1==3) print $2 > "output_file" print "1" > "new_file" }' "input_file" When I check output_file this has the correct values in it. However the new_file has 1 in it for every line in the input_file. If the input file has 20 lins then... (2 Replies)
Discussion started by: Donkey25
2 Replies

3. Shell Programming and Scripting

Explanation for printf string in awk

hi all can any one help me to understand this bdf -t vfxs | awk '/\//{printf("%-30s%-10s%-10s%-10s%-5s%-10s\n",$1,$2,$3,$4,$5,$6)}' i want to understand the numbers %-30S% (4 Replies)
Discussion started by: maxim42
4 Replies

4. Shell Programming and Scripting

awk explanation

Hello, I have recently come across this awk program. Can some one shed some light on what is taking place. awk '{!a++}END{for(i in a) if ( a >10 ) print a,i }' $FILE Best Regards, jaysunn (1 Reply)
Discussion started by: jaysunn
1 Replies

5. Shell Programming and Scripting

Help with explanation of awk parameters

Hello, Would someone be able to tell me exactly how this command works please? awk '!x++' As usual any help much appreciated (8 Replies)
Discussion started by: Grueben
8 Replies

6. Shell Programming and Scripting

Sysdate inside awk print statement

Hi, I am using awk statement to extract data from a file and write a new file with certain columns rearranged and few hard coded values added to new file. Now i need to add a column with sysdate. can i do that inside the awk print statement? Now: nawk ' /^3/ BEGIN {FS=","}... (2 Replies)
Discussion started by: selvankj
2 Replies

7. Shell Programming and Scripting

use awk print statement for two files

Hello, is there a way to use the awk print statement on two files at once? I would like to take two columns from one file, and one column from another file and print them as consecutive columns to a third file. Seems simple...as in: file 1 1 a 2 b 3 c 4 d 5 e file 2 1 t 2 u... (3 Replies)
Discussion started by: HugoHuhn
3 Replies

8. Shell Programming and Scripting

Awk find in columns with "if then" statement and print results

I have a file1.txt file1.txt 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"... (4 Replies)
Discussion started by: charles33
4 Replies

9. UNIX for Dummies Questions & Answers

If statement explanation

Could anyone please advise what the in the following if statement means? if ; then Thank you. (2 Replies)
Discussion started by: jimbojames
2 Replies

10. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies
Jcode::Nihongo(3pm)					User Contributed Perl Documentation				       Jcode::Nihongo(3pm)

I3/4Ao
       Jcode - AEuEU,iE,>>u1/2,1cYIYoYEYe

3uIx
	use Jcode;
	#		 _
	# ,A1/4oxaex<<x.x
	Jcode::_onvert($str_ $ocode, $icode, "z");
	# xax.x xIYaYOY,YSY YE>>O,bxCia
	print Jcode->new($str)->h2z->tr($from, $to)->utf8;

AaIA			  _
       Jcode.pmxIYaYOY,YSY YEAaxEYcYxYi_1/4YAxE1/23/4Iex<<xexIYcYxYii1/4YAxII3/4Eyxo
       YuYYi1/4YEx.xAExxxbx1iLYaYOY,YSY YEAaxEYcYxYii1/4YAxo>>Ex"xDx3xoxE'9|x,xCi"

	 $iso_2022_jp = Jcode->new($str)->h2z->jis;

       x3xAxexexeY"YiY~YoYExCx.xcx|iS

	 $iso_2022_jp = $str;
	 &jcode::convert($iso_2022_jp, 'jis', &jcode::getcode($str), "z");
		_
       YaYOY,YSY YExEAEeA-:-xBxIIuxxcIxIxcxaxEicJcode.pmxIxbxA"getcode()"xE "convert()"xoYuYYi1/4YEx.xAExxxbx1iL

       PerlxIYDi1/4Y,YcYox~5.8.1oE3/4axExeicJcodexIicPerl 5.8oE1BxIE,1/2aAaxEE,>>u1/2,1c
       YIYoYEYeYaY,Yai1/4YexCxcxeEncodexIYeYAYNi1/4xEx.xAEc9|xeEnxxxbx1iL

YaY1/2YAYE							       _
       AEAxE,AuUx.xExx,Axeicx3x3xCuox2xeYaY1/2YAYExIA'xAEJcodeYaYOY,YSY YExoEOx.xbx1iL
		  _
       Y3YoY1YEYeY Yc

       $j = Jcode->new($str [, $_code])
	 $strx<<xeJcodeYaYOY,YSY YE$jxoA,A(R)x.xbx1iLIA1/4"AaxE$icodexoY>>YAYEx.xEx+-xixDic			     _
	 AEbIIY3i1/4YExI1/4<<AEoAaxEE1/2Aexuxixbx1iLIoIN2AC1/2xEE,>>u1/2,1cxExAxxxAExIic21/4xI getcodexo>>23/4Ex.xAEx xAxuxxiL

	 Perl 5.8.1oE1BxCxIic$icodexExIEncodex~Iy2oxCxxe xExoxEY"YoY3i1/4YCYLYoYoI3/4xa>>Ex"xbx1iL

	   $j = Jcode->new($european, 'iso-latin1');
		  _
	 YaYOY,YSY YExoE,>>uIo21/2x1xexEicEUCxEEN'1xuxixcE,>>uIox~EOxexbx1iLxCx1x<<xe "print $j->euc"xEx1xeAaxixexEic"print $j"xExCxxbx1iL

	 YeYOYiYiYoY1AIx.
	   Y1Y<<Yei1/4AIxIAaxixexEicoE21/4xIxex|xEYeYOYiYiYoY1xoAIx>>xbx1iL

	    Jcode->new($str);
			  _
	   x3xixIxUxoxI3/4 x.>>b'OxoAaIox.xbx1iLx1/2xIA_1/2bxEx.xAEic$strxIAIx1/2xIxaxIx~
	   EN'1xuxixbx1iExcxeoOILic$strxIjcodeYaYOY,YSY YExE"tiexuxixe"xIxCx1iEiL

       $j->set($str [, $icode]) 				       _
	 $jxIAEaEoE,>>uIoxE$_trxoY>>YAYEx.xbx1iL.<<xeEOx.JcodeYaYOY,YSY YExo>>Ex|xExxE
	 EOIoxCx1iEYaYOY,YSY YExoA,A(R)x1xe>>b'OxEYaYaYexIAaIoxExExexbx1iEiL

	  # mailboxxoSJIS.A1/4oxEEN'1
	  my $jconv = new Jcode;
	  $/ = 00;
	  while(<>){
	      print $jconv->set($_)->mime_decode->sjis;
	  }

       $j->append($str [, $icode]);
	 $jxIAEaEoE,>>uIoxE$strxo2Ax"xbx1iL

       $j = jcode($str [, $icode]);
	 Jcode->new() xIA>>1/2I.AiLoE21/4xIxex|xExCxxbx1i"

	  $sjis = jcode($str)->sjis;

       E,>>uIoxIY"YoY3i1/4YE

       oiEIxEic$j->encodedxEx1xex3xExCencodedxEEN'1xuxixcE,>>uIoxoAEAxbx1iL

       $sjis = $j->sjis
       $euc = $j->euc
       $jis = $j->jis
       $sjis = $j->sjis
       $ucs2 = $j->ucs2
       $utf8 = $j->utf8
	 1/4<<IAxCx.xcx|iL WYCIWYG = What you code is what you get :)

       $iso_2022_jp = $j->iso_2022_jp		     _
	 "$j->h2z->jis"xEAE+-x,xCx1iL E3/43NY<<YExI9| A(C)AaxEA'3NxEEN'1xuxixbx1iL

	 Perl 5.8.1oE1BxCxIicEncodex~YuYYi1/4YEx1xexExoxEY"YoY3i1/4YCYLYoYoI3/4xE Y"YxYeYcY1xCxaIoINxCxxbx1iLIax"xDiS

	   $european = $j->iso_latin1; # YaY1/2YAYEI3/4INxE'-'xI'_'xEAOx'1x"xbx1

	 >>21IiSEncode::Encoderx~x3xixEAE+-x,3/4(R)u>>xo>>ExAxAExxxbx1iL

	 $j->fallback($fallback)
	   Perl 5.8.1oE1BxCxIicJcodexIAEaEoxIE,>>uIoxoUTF-8xCEY>>yx.xbx1iL ->encodingxEYbYAYxxCxxExxE,>>uxI'?'xEAOx'1x"xexixbx1x~ic
	   x3xixIEncodexCxIE,1/2aAEooixCx1iL
						    _
	     my $unistr = "x{262f}"; # +-cIUYbi1/4Y
	     my $j = jcode($unistr);  # $j->euc xI.e2IxI '?' xE
							   _
	   x3xIc9|xeEnxxxIicEncodeAE+-IIicYOY(C)i1/4YeYDYAY xo>>OAex1xex3xExCEN11xCxxbx1iL
	   AIxIEncodexIxaxIxEoi1/2ixCx1iLEOu1xIxcxaic"Jcode::FB_PERLQQ"ic "Jcode::FB_XMLCREF"ic"Jcode::FB_HTMLCREF"x~EncodexIx1/2xixexOxI
	   Y"YxYeYcY1xExExAxAExxxbx1iL

	     print $j->fallback(Jcode::FB_PERLQQ)->euc;   # 'x{262f}'
	     print $j->fallback(Jcode::FB_XMLCREF)->euc;  # '&#x262f;'
	     print $j->fallback(Jcode::FB_HTMLCREF)->euc; # '&#9775;'
									    _
	   YoYii1/4YDYeENco$Jcode::FALLBACKxEYCYOY(C)YeYExIYOY(C)i1/4YeYDYAY x~EY>>y
	   xuxixAExxxbx1xIxCicx3xIAIxoAaAEbx1xex3xExCYai1/4YDi1/4YeYxYExCxxbx1iL
										   _
	     $Jcode::FALLBACK = Jcode::FB_PERLQQ; # YCYOY(C)YeYExIYOY(C)i1/4YeYDYAY Y1Yi1/4YbxoABAe

       [@lines =] $jcode->jfold([$width, $newline_str, $kref])
	 $widthiEYCYOY(C)YeYEiS72iEEexEjcodeE,>>uIoAEaxI1OxoAbxeEOx.xbx1iL
	 $widthxIiEE3/43NiEE,>>uxIcoxCx1iLA'3NE,>>uxI2E,>>uxEx.xAEY<<Y|YoYEx.xbx1iL

	 $newline_striEYCYOY(C)YeYExI"
"iExC>>OAexuxixc2b1OE,>>ux~2Axixexbx1iL AbxeEOxuxixcA'1OxoYeY1YExCEOx.xbx1iL

	 Perl 5.8.1oE1BxI3EOIUxIouco$krefxEEUCxIE,>>uIoxICUIoYeYOYiYiYoY1xo AIx1x3xExCic'EoxAaxE1OAE~9|OAS1/2eIyiExOxe21/4x~xeiExo1Ox"xbx1iL

       $length = $jcode-_jlength();
	 YDYxYEA1xCxIxEx icA'3NE,>>uxaoiE,>>uxEx.xAEcox"xc3/4i1cxIE,>>ucoxoEOx.xbx1iL

       MIME::Base64xo>>Ex|YaY1/2YAYE

       21/4uxIYaY1/2YAYExo>>Ex|xExIicMIME::Base64x~E~IxxCx1iLYxYoY1YEi1/4YexIA+-1/2axE

	  perl -MCPAN -e 'CPAN::Shell->install("MIME::Base64")'

       xEx.xbx1iLxa>>ExxxIPerlx~5.6oE1BxCxcxexExeicMIME::Base64xI YDYoYEYexuxixAExxxexIxCicYxYoY1YEi1/4YexIE~IxxIxcxexbx>>xoiL

       $mime_header = $j->mime_encode([$lf, $bpl])
	 $strxoRFC1522xExcxeMIME-HeaderxEEN'1x.xbx1iL$lfxo>>OAex1xexEic 1OxIAbxeEOx.xE$lfx~>>Exixixbx1iEYCYOY(C)YeYEiS
iEiL
	 $bplxo>>OAex1xexEicAbxeEOx1YDYxYEcoxE$bplx~>>Exixixbx1iEYCYOY(C)YeYEiS76i" x3xIcoAIxI76oE21/4xCxEx+-xixDxExexbx>>xoiEiL

	 Perl 5.8.1oE1BxCxIicoE21/4xIxex|xEx.xAExaMIME HeaderY"YoY3i1/4YEx~xCxxbx1iS

	   $mime_header = $j->MIME_Header;

	 x3xI3/4i1c$mime_headerxIIaxeAIxIMIME-B-encoded UTF-8xExExexbx1iL oiEyic"$j->mime_encode()"xIMIME-B-encoded ISO-2022-JPxoEOx.xbx1iL
	 oC9|axIxUxExoxExIYai1/4Yei1/4xIxExAxexaYuYYi1/4YEx.xAExxxbx1iL

       $j->mime_decode;_
	 JcodeYaYOY,YSY YExIAEaEoE,>>uIoxoMIME-HeaderYCY3i1/4YEx.xbx1iLPerl 5.8.1 oE1BxExeicoE21/4xIxex|xEx.xAEAE+-x,x3xEx~xCxxbx1iS

	   Jcode->new($str, 'MIME-Header');
						_
	 x3xAxexI3/4i1cicISO-2022-JPxAx+-xCxIxEx UTF-8xExExExaAD+-bx.xAExaxeic xuxexEMIME B EncodingxIxBxExexoMIME Q EncodingxExaAD+-bx.xAExxxe
	 xIxCicPerl 5.8.1oE1BxCxcxixDx3xAxexo>>Ex|xUxxCx.xcx|iL

       E3/43N c<<ca A'3N

       $j->h2z([$keep_dakuten])
	 X201Y<<YEiEE3/43NiExoX208Y<<YEiEA'3NiExEEN'1x.xbx1iL $keep_dakutenxEccAIxoY>>YAYEx1xexEicAuAAxox1/2xIxbxbxEx.xbx1
	 (x3xixIxAxbxeiciOY<<iUi<<ixxIiOY~ixxEEN'1xuxixoxEx1/2xIxbxb xExExexExxx|x3xExCx1)

	 $j->nmatchxoAIx,xAEYbYAYAx.xccoxo1/4eAEAxCxxbx1iL

       $j->z2h
	 X208Y<<YEiEA'3NiExoX201Y<<YEiEE3/43NiExEEN'1x.xbx1iL

	 $j->nmatchxoAIx,xAEYbYAYAx.xccoxo1/4eAEAxCxxbx1iL

       Auu~E1/2,1/2Y"YBYaYii1/4Yc

       "->m()"xE"->s()"xo>>Ex|xExIicPerl 5.8.1oE1Bx~ E~IxxCx1iL

       $j->tr($from, $t_, $opt);
	 JcodeYaYOY,YSY YExE"tr/$from/$to/"xoA~INx.xbx1iL$fromxE$toxI EUC-JPxIE,>>uIoxCx1iLPerl 5.8.1oE1BxCxIicflagEOxxIUTF-8E,>>uIo
	 xa1/4ox+-EOx+-xbx1iL

	 $optxoY>>YAYEx1xexEic"tr/$from/$to/$opt"x~A~INxuxixbx1iL$optxI 'c'ic'd'xcxexxxIx1/2xixexIAExB1cxix>>xCxEx+-xixDxExexbx>>xoiL

	 $j->nmatchxoAIx,xAEYbYAYAx.xccoxo1/4eAEAxCxxbx1iL

	 Perl 5.8.1oE1BxCxIictrxI.A1/4oxE,ixexIxcxAxc3/4i1cxE->error_trxoAIx,xAEic $@xo1/4eAEAxCxxbx1iL

	 oE21/4xIYaY1/2YAYExIPerl 5.8.1oE1BxCxIxBIoIN2AC1/2xCx1iL

       $j->s($patter, $replace, $opt);
	 ,Ai1xE"s/$pattern/$replace/$opt"xoA~INx.xbx1iL$optxIAuu~E1/2,1/_YaYxY.YcYoxE
	 AE+-x,xCx1iLAuu~E1/2,1/2xIYaYxY.YcYoxExAxxxAExIperlrexo>>23/4Ex xAxuxxiL
					       _
	 "$j->tr()"ic"$j->s()"xIx1/2xIYaYOY,YSY YE1/4<<cExoEOx1xIxCic oE21/4xIxex|xEAaoixoIc.exCxxbx1iL

	   $j->tr("A-Z", "a-z")->s("foo", "bar");

       [@match = ] $j->m($pattern, $opt);			  _
	 "m/$patter/$opt"xoA~_Nx.xbx1iLx3xIYaY1/2YAYExIiEYaYOY,YSY YExoEOxuxExxiE xIxCic"$j->s()"xIxex|xEYaY1/2YAYExoIc.exCx-
	 xExxx3xExEAioOx.xAEx xAxuxxiL

	 Auu~E1/2,1/2xI.A1/4oxE,ixexIxcxAxc3/4i1cic->error_mic->error_sxoAIx,xAE $@xo1/4eAEAxCxxbx1iL

       YxYoY1YcYoY1ENco
			 _			   _
       xax.J_odeYaYOY,YSY YExIY_YoY1Y_YoY1ENcoxEYcY Y>>Y1x.xcxxxExeicA3/4AUx1/2xixe
       xEYcY Y>>Y1x1xexIxCxIxEx icYcY Y>>Y1YaY1/2YAYExoIoINx.xbx.xcx|iEx3xix3/4OOP xCx1iEiL

       >>21IxbxCxEicJcodexIiEoiEIAaxEEyEixCxcxeiEYIYAY.YaYeYOYiYiYoY1xIAaxixexEic
       CUI_YeYOYiYiYoY1xo>>Ex|x3xExCicY1YOi1/4YExooCA~21/2x.xAExxxbx1iE1/4AoYxIxEx3xiic
       YcY Y>>Y1YaY1/2YAYExo>>Ex|,Axex3xIx3xExoAIxeE~IxxIxcxexbx>>xoi" xax|oiAU xxxxxbx1x~icx3xixIOOPxExIxCx1iEiL

       Perl 5.8.1oE1BxCxIicYIYAY.YaYeYOYiYiYoY1xo>>Ex|xex|xEEN11xuxixbx.xciL x3xixExexeicJcodexI3EAYxIxaxIx1x'x 'EA+-xExExexbx1iL

       $j->r_str
	 EUCE,>>uIoxOxIYeYOYiYiYoY1iL

	 Perl 5.8.1oE1BxCxIUTF-8YOYeYoxII(C)xAxcUTF-8E,>>uIoxOxIYeYOYiYiYoY1xCx1iL

       $j->icode
	 A3/49|axIAaoixExax+-xeAEbIIE,>>uY3i1/4YEiL

       $j->nmatch
	 YbYAYAx.xccoiE$j->trAuxo>>ExAxcxExiEiL

YuYOYei1/4YAYo
       ($code, [$nmatch]) = getcode($str)
	 $strxIE,>>uY3i1/4YExoEOx.xbx1iLEOxeY3i1/4YExIoE21/4xIAIxexCx1iL

	  ascii   Ascii iEAEuEU,iY3i1/4YExo'bxbxExxiE
	  binary  Binary iEYAEYY1YEYOYiYxYexCxIxExxiE
	  euc	  EUC-JP
	  sjis	  SHIFT_JIS
	  jis	  JIS (ISO-2022-JP)
	  ucs2	  UCS2 (Raw Unicode)
	  utf8	  UTF8

	 Y1Y<<Yei1/4Y3YoYAEYY1YExIAaxixexECUIoY3YoYAEYY1YExo>>Ex|xEic2cE,>>uE~xI
	 Y3i1/4YEx~,<<xAx<<xAxcxIx<<xaEOx.xbx1iL3/4axIEyxC1/2OxUxcxex|xEic$strxI$str xCxa11/2xxxbx>>xoiL

	 jcode.pl IoIN1/4OxIEyxOiS x3xI'OcoxIjcode::getcode()xE100%3/4aoI,B'1x~ xcxexbx1iLi1/2i1/2xbxcicxUxU100%i"

	  * IaxeAIx~CUIoxIxExicx1/2xI1/2cEOxIuOxExExexbx1i"
	    jcode::getcode()xI$nmatchxooC1/2exEEOx.xbx1iL

	  * jcode::getcode()xIicEUCE,>>uxESJISE,>>uxIcox~Aux.xxxExic'undef'xo
	    EOx.xbx1iL Jcode::getcode()xIEUCxoEOx.xbx1iLx3xixIJcode.pmxExI
	    Aae'Ox~xExxxcxaxCx1iL

       Jcode::convert($str, [$ocode, $icode, $opt])
	 $strxo$ocodexC>_OAex.xcE,>>uY3i1/4YExEEN'1x.xbx1iL$icodexa>>OAex1xexEic AEbIIE,>>uIoxoget-
	 code()xCYAYSYAY x1xeAaxixexEic$icodexE23/4Aex.xbx1iL 3/4axIEyxC1/2OxUxcxex|xEic$strxI$strxCxa11/2xxxbx>>xoiL

	 jcode.pl IoIN1/4OxIEyxOiS x3xI'OcoxIjcode::convert()xE100%3/4aoI,B'1x~ xcxexbx1ia

YDYo
       Perlx~5.8.1oE1BxI3/4i1cicJcodexIEncodexIYeYAYNi1/4xEx.xAEc9|xeEnxxxbx1iL xAxbxeicJcodexIEncodeAEaxIYDYoxI+-AE9|Axo1/4ox+-xbx1iL

1/4O1/4 							  _
       x3xIYNYAY+-i1/4Y,xIicAEouiicYCY9|YxYox1/2x.xAEY3i1/4YExIAcx xIAAxCic 2IAa IAAu
       <utashiro@iij.ad.jp>>>axIPerl4YeYxYOYeYejcode.plxEEexAxAExxxbx1iL
						    _									   _
       Acoe Ci'o <ohzaki@iod.ricoh.co.jp>>>axIic3<<E xIEo3/4ixE1/2e'uxIAE3~x<<xe Auu~E1/2,1/2xoEaxxcx2xe1/4e1/2ox+-xox.xAEx xixbx.xciL

       makamaka@donzoko.net xI JEncode xExIicJcodexEEncodexoxEx|I>>1cxux>>xixD xxxxx<<AcENAcx-
       xE.1/41/4"xo1/4ox+-xbx.xciLxbxcicEUAEuEU,iYbYEYaYcYexa'oALx.xAE xxxcxAxxbx.xciL

       x1/2x.xAEJcode ML <jcode5@ring.gr.jp>xI3SxuxoiLx3xIEyALxEx.xExIic x3x3xbxC'oA(R)x.xEx<<xAxcx3xExCx.xcx|iL

>>21I
       Encode

       <http://www.iana.org/assignments/character-sets>

Aooi,c
       Copyright 1999-2005 Dan Kogai <dankogai@dan.co.jp>

       This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

perl v5.8.8							    2005-02-19						       Jcode::Nihongo(3pm)
All times are GMT -4. The time now is 07:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy