Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Print last 4 columns (variable column #) Post 48057 by Da_Duck on Wednesday 25th of February 2004 05:58:37 PM
Old 02-25-2004
wow. thanks!
That did it.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

can awk print column using a variable ??

i want to print the column file using awk or cut in dynamic manner like trmp=2;temp1=1;temp3=2 awk 'BEGIN{OFS=IFS="\t"} {print $temp,$temp1,$temp3}' client_data.txt or cut -f $temp1,$temp2,$temp3 -d"\t" file_name . but it is showing error , In awk can i use variable as in printing... (36 Replies)
Discussion started by: jambesh
36 Replies

2. Shell Programming and Scripting

How to check Null values in a file column by column if columns are Not NULLs

Hi All, I have a table with 10 columns. Some columns(2nd,4th,5th,7th,8th and 10th) are Not Null columns. I'll get a tab-delimited file and want to check col by col and generate seperate error code for each col eg:102 if 2nd col value is NULL and 104 if 4th col value is NULL so on... I am a... (7 Replies)
Discussion started by: Mandab
7 Replies

3. UNIX for Dummies Questions & Answers

How to copy one columns and print to the last column in unix?

I want to copy column no 3 to the end of column example : alter table RECOVER_USR.MPULKIXD rename to alter table RECOVER_USR.CS_ADV_PROMO rename to alter table RECOVER_USR.BCH_HISTORY_TABLE rename to alter table BILLOPS.HISHAM_DATAPLUS_FINAL rename to alter table... (8 Replies)
Discussion started by: arifahel
8 Replies

4. Solaris

awk - Print variable number of colums from a starting column

Hi guys, I usualy am able to google awk stuff but I can't find it so far and there are so many awking gurus here that I will give it a shot. I want to print $1;$3;"$5 up to the $NF". In other words, I can have 1000 colums, but need to have $5 up to the end. I started with the idea of... (2 Replies)
Discussion started by: plmachiavel
2 Replies

5. Shell Programming and Scripting

Need to find a column from one file and print certain columns in second file

Hi, I need helping in finding some of the text in one file and some columns which have same column in file 1 EG cat file_1 aaaa bbbb cccc dddd eeee fffff gggg hhhh cat file_2 aaaa,abcd,effgh,ereref,name,age,sex,........... bbbb,efdfh,erere,afdafds,name,age,sex.............. (1 Reply)
Discussion started by: jpkumar10
1 Replies

6. Shell Programming and Scripting

Combine columns from many files but keep them aligned in columns-shorter left column issue

Hello everyone, I searched the forum looking for answers to this but I could not pinpoint exactly what I need as I keep having trouble. I have many files each having two columns and hundreds of rows. first column is a string (can have many words) and the second column is a number.The files are... (5 Replies)
Discussion started by: isildur1234
5 Replies

7. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

8. Shell Programming and Scripting

awk print columns and variable

Hi, Can anyone help with the below please? I have written some code which takes an input file, and and prints the contents out to a new file - it then loops round and prints the same columns, but increments the ID column by 1 each time. Input file; NAME,1,15-Dec-15, NAME,1,21-Dec-15,... (9 Replies)
Discussion started by: Ads89
9 Replies

9. Shell Programming and Scripting

awk to Sum columns when other column has duplicates and append one column value to another with Care

Hi Experts, Please bear with me, i need help I am learning AWk and stuck up in one issue. First point : I want to sum up column value for column 7, 9, 11,13 and column15 if rows in column 5 are duplicates.No action to be taken for rows where value in column 5 is unique. Second point : For... (1 Reply)
Discussion started by: as7951
1 Replies

10. Shell Programming and Scripting

Adding columns from 2 files with variable number of columns

I have two files, file1 and file2 who have identical number of rows and columns. However, the script is supposed to be used for for different files and I cannot know the format in advance. Also, the number of columns changes within the file, some rows have more and some less columns (they are... (13 Replies)
Discussion started by: maya3
13 Replies
Template::Alloy::Operator(3pm)				User Contributed Perl Documentation			    Template::Alloy::Operator(3pm)

NAME
Template::Alloy::Operator - Operator role. DESCRIPTION
The Template::Alloy::Operator role provides the regexes necessary for Template::Alloy::Parse to parse operators and place them in their appropriate precedence. It also provides the play_operator method which is used by Template::Alloy::Play and Template::Alloy::Compile for playing out the stored operator ASTs. ROLE METHODS
play_operator Takes an operator AST in the form of [undef, '+', 1, 2] Essentially, all operators are stored in RPN notation with a leading "undef" to disabiguate operators in a normal Alloy expression AST. define_operator Used for defining new operators. See Template::Alloy for more details. OPERATOR LIST
The following operators are available in Template::Alloy. Except where noted these are the same operators available in TT. They are listed in the order of their precedence (the higher the precedence the tighter it binds). "." The dot operator. Allows for accessing sub-members, methods, or virtual methods of nested data structures. my $obj->process($content, {a => {b => [0, {c => [34, 57]}]}}, $output); [% a.b.1.c.0 %] => 34 Note: on access to hashrefs, any hash keys that match the sub key name will be used before a virtual method of the same name. For example if a passed hash contained pair with a keyname "defined" and a value of "2", then any calls to hash.defined(another_keyname) would always return 2 rather than using the vmethod named "defined." To get around this limitation use the "|" operator (listed next). Also - on objects the "." will always try and call the method by that name. To always call the vmethod - use "|". "|" The pipe operator. Similar to the dot operator. Allows for explicit calling of virtual methods and filters (filters are "merged" with virtual methods in Template::Alloy and TT3) when accessing hashrefs and objects. See the note for the "." operator. The pipe character is similar to TT2 in that it can be used in place of a directive as an alias for FILTER. It similar to TT3 in that it can be used for virtual method access. This duality is one source of difference between Template::Alloy and TT2 compatibility. Templates that have directives that end with a variable name that then use the "|" directive to apply a filter will be broken as the "|" will be applied to the variable name. The following two cases will do the same thing. [% foo | html %] [% foo FILTER html %] Though they do the same thing, internally, foo|html is stored as a single variable while "foo FILTER html" is stored as the variable foo which is then passed to the FILTER html. A TT2 sample that would break in Template::Alloy or TT3 is: [% PROCESS foo a = b | html %] Under TT2 the content returned by "PROCESS foo a = b" would all be passed to the html filter. Under Template::Alloy and TT3, b would be passed to the html filter before assigning it to the variable "a" before the template foo was processed. A simple fix is to do any of the following: [% PROCESS foo a = b FILTER html %] [% | html %][% PROCESS foo a = b %][% END %] [% FILTER html %][% PROCESS foo a = b %][% END %] This shouldn't be too much hardship and offers the great return of disambiguating virtual method access. "" Unary. The reference operator. Not well publicized in TT. Stores a reference to a variable for use later. Can also be used to "alias" long names. [% f = 7 ; foo = f ; f = 8 ; foo %] => 8 [% foo = f.g.h.i.j.k; f.g.h.i.j.k = 7; foo %] => 7 [% f = "abcd"; foo = f.replace("ab", "-AB-") ; foo %] => -AB-cd [% f = "abcd"; foo = f.replace("bc") ; foo("-BC-") %] => a-BC-d [% f = "abcd"; foo = f.replace ; foo("cd", "-CD-") %] => ab-CD- "++ --" Pre and post increment and decrement. My be used as either a prefix or postfix operator. [% ++a %][% ++a %] => 12 [% a++ %][% a++ %] => 01 [% --a %][% --a %] => -1-2 [% a-- %][% a-- %] => 0-1 "** ^ pow" Right associative binary. X raised to the Y power. This isn't available in TT 2.15. [% 2 ** 3 %] => 8 "!" Prefix not. Negation of the value. "-" Prefix minus. Returns the value multiplied by -1. [% a = 1 ; b = -a ; b %] => -1 "*" Left associative binary. Multiplication. "/ div DIV" Left associative binary. Division. Note that / is floating point division, but div and DIV are integer division. [% 10 / 4 %] => 2.5 [% 10 div 4 %] => 2 "% mod MOD" Left associative binary. Modulus. [% 15 % 8 %] => 7 "+" Left associative binary. Addition. "-" Left associative binary. Minus. "_ ~" Left associative binary. String concatenation. [% "a" ~ "b" %] => ab "< > <= >=" Non associative binary. Numerical comparators. "lt gt le ge" Non associative binary. String comparators. "eq" Non associative binary. String equality test. "==" Non associative binary. In TT syntaxes the V2EQUALS configuration item defaults to true which means this operator will operate the same as the "eq" operator. Setting V2EQUALS to 0 will change this operator to mean numeric equality. You could also use [% ! (a <=> b) %] but that is a bit messy. The HTML::Template syntaxes default V2EQUALS to 0 which means that it will test for numeric equality just as you would normally expect. In either case - you should always use "eq" when you mean "eq". The V2EQUALS will most likely eventually default to 0. "ne" Non associative binary. String non-equality test. "!=" Non associative binary. In TT syntaxes the V2EQUALS configuration item defaults to true which means this operator will operate the same as the "ne" operator. Setting V2EQUALS to 0 will change this operator to mean numeric non-equality. You could also use [% (a <=> b) %] but that is a bit messy. The HTML::Template syntaxes default V2EQUALS to 0 which means that it will test for numeric non-equality just as you would normally expect. In either case - you should always use "ne" when you mean "ne". The V2EQUALS will most likely eventually default to 0. "<=>" Non associative binary. Numeric comparison operator. Returns -1 if the first argument is less than the second, 0 if they are equal, and 1 if the first argument is greater. "cmp" Non associative binary. String comparison operator. Returns -1 if the first argument is less than the second, 0 if they are equal, and 1 if the first argument is greater. "&&" Left associative binary. And. All values must be true. If all values are true, the last value is returned as the truth value. [% 2 && 3 && 4 %] => 4 "||" Right associative binary. Or. The first true value is returned. [% 0 || '' || 7 %] => 7 Note: perl is left associative on this operator - but it doesn't matter because || has its own precedence level. Setting it to right allows for Alloy to short circuit earlier in the expression optree (left is (((1,2), 3), 4) while right is (1, (2, (3, 4))). "//" Right associative binary. Perl 6 err. The first defined value is returned. [% foo // bar %] ".." Non associative binary. Range creator. Returns an arrayref containing the values between and including the first and last arguments. [% t = [1 .. 5] %] => variable t contains an array with 1,2,3,4, and 5 It is possible to place multiple ranges in the same [] constructor. This is not available in TT. [% t = [1..3, 6..8] %] => variable t contains an array with 1,2,3,6,7,8 The .. operator is the only operator that returns a list of items. "? :" Ternary - right associative. Can be nested with other ?: pairs. [% 1 ? 2 : 3 %] => 2 [% 0 ? 2 : 3 %] => 3 "*= += -= /= **= %= ~=" Self-modifying assignment - right associative. Sets the left hand side to the operation of the left hand side and right (clear as mud). In order to not conflict with SET, FOREACH and other operations, this operator is only available in parenthesis. [% a = 2 %][% a += 3 %] --- [% a %] => --- 5 # is handled by SET [% a = 2 %][% (a += 3) %] --- [% a %] => 5 --- 5 "=" Assignment - right associative. Sets the left-hand side to the value of the righthand side. In order to not conflict with SET, FOREACH and other operations, this operator is only available in parenthesis. Returns the value of the righthand side. [% a = 1 %] --- [% a %] => --- 1 # is handled by SET [% (a = 1) %] --- [% a %] => 1 --- 1 "not NOT" Prefix. Lower precedence version of the '!' operator. "and AND" Left associative. Lower precedence version of the '&&' operator. "or OR" Right associative. Lower precedence version of the '||' operator. "err ERR" Right associative. Lower precedence version of the '//' operator. "->" (Not in TT2) Macro operator. Works like the MACRO directive but can be used in map, sort, and grep list operations. Syntax is based on the Perl 6 pointy sub. There are two diffences from the MACRO directive. First is that if no argument list is specified, a default argument list with a single parameter named "this" will be used. Second, the "->" operator parses its block as if it was already in a template tag. [% foo = ->{ "Hi" } %][% foo %] => Hi [% foo = ->{ this.repeat(2) } %][% foo("Hi") %] => HiHi [% foo = ->(n){ n.repeat(2) } %][% foo("Hi") %] => HiHi [% foo = ->(a,b){ a; "|"; b } %][% foo(2,3) %] => 2|3 [% [0..10].grep(->{ this % 2 }).join %] => 1 3 5 7 9 [% ['a'..'c'].map(->{ this.upper }).join %] => A B C [% [1,2,3].sort(->(a,b){ b <=> a }).join %] prints 3 2 1 [% c = [{k => "wow"}, {k => "wee"}, {k => "a"}] %] [% c.sort(->(a,b){ a.k cmp b.k }).map(->{this.k}).join %] => a wee wow Note: Care should be used when attempting to sort large lists. The mini-language of Template::Alloy is a interpreted language running in Perl which is an interpreted language. There are likely to be performance issues when trying to do low level functions such as sort on large lists. The RETURN directive and return item, list, and hash vmethods can be used to return more interesting values from a MACRO. [% a = ->(n){ [1..n].return } %] [% a(3).join %] => 1 2 3 [% a(10).join %] => 1 2 3 4 5 6 7 8 9 10 The Schwartzian transform is now possible in Template::Alloy (somebody somewhere is rolling over in their grave). [%- qw(Z a b D y M) .map(->{ [this.lc, this].return }) .sort(->(a,b){a.0 cmp b.0}) .map(->{this.1}) .join %] => a b D M y Z "{}" This operator is not exposed for external use. It is used internally by Template::Alloy to delay the creation of a hash until the execution of the compiled template. "[]" This operator is not exposed for external use. It is used internally by Template::Alloy to delay the creation of an array until the execution of the compiled template. "@()" List context specifier. Methods or functions inside this operator will always be called in list context and will always return an arrayref of the results. See the CALL_CONTEXT configuration directive. "$()" Item context specifier. Methods or functions inside this operator will always be called in item (scalar) context. See the CALL_CONTEXT configuration directive. "qr" This operator is not exposed for external use. It is used internally by Template::Alloy to store a regular expression and its options. It will return a compiled Regexp object when compiled. "-temp-" This operator is not exposed for external use. It is used internally by some directives to pass temporary, literal data into play_expr to allow additional vmethods or filters to be called on existing data. AUTHOR
Paul Seamons <paul at seamons dot com> LICENSE
This module may be distributed under the same terms as Perl itself. perl v5.10.1 2008-04-10 Template::Alloy::Operator(3pm)
All times are GMT -4. The time now is 01:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy