Sponsored Content
Top Forums Shell Programming and Scripting Changing the column for a row in a text file and adding another row Post 70460 by SSteve on Thursday 28th of April 2005 10:52:04 PM
Old 04-28-2005
Ok, I got a similar (but not exactly identical) result by leaving out "{ print $0; lastrow = $0 }". Are you sure there isn't a typo somewhere? Try copying the code directly from your message, because that code works fine.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Adding a column with the row number using awk

Is there anyway to use awk to add a first column to my data that automatically goes from 1 to n , where n is the numbers of my rows?:confused: (4 Replies)
Discussion started by: cosmologist
4 Replies

2. UNIX for Dummies Questions & Answers

How do you delete cells from a space delimited text file given row and column number?

How do you delete cells from a space delimited text file given row and column number? Letś say the row number is r and the column number is c. Thanks! (5 Replies)
Discussion started by: evelibertine
5 Replies

3. Shell Programming and Scripting

Subtracting each row from the first row in a single column file using awk

Hi Friends, I have a single column data like below. 1 2 3 4 5 I need the output like below. 0 1 2 3 4 where each row (including first row) subtracting from first row and the result should print below like the way shown in output file. Thanks Sid (11 Replies)
Discussion started by: ks_reddy
11 Replies

4. UNIX for Dummies Questions & Answers

Adding a column to a text file with row numbers

Hi, I would like to add a new column containing the row numbers to a text file. How do I go about doing that? Thanks! Example input: A X B Y C D Output: A X 1 B Y 2 C D 3 (5 Replies)
Discussion started by: evelibertine
5 Replies

5. UNIX for Dummies Questions & Answers

awk to print first row with forth column and last row with fifth column in each file

file with this content awk 'NR==1 {print $4} && NR==2 {print $5}' file The error is shown with syntax error; what can be done (4 Replies)
Discussion started by: cdfd123
4 Replies

6. Shell Programming and Scripting

Print row on 4th column to all row

Dear All, I have input : SEG901 5173 9005 5740 SEG902 5227 5284 SEG903 5284 5346 SEG904 5346 9010 SEG905 5400 5456 SEG906 5456 5511 SEG907 5511 9011 SEG908 5572 9015 SEG909 5622 9020 SEG910 5678 5739 SEG911 5739 5796 SEG912 5796 9025 ... (3 Replies)
Discussion started by: attila
3 Replies

7. Shell Programming and Scripting

Script changing row to column

Hi Gurus, I have an I/P file which looks like 100 1 200 1 300 4 100 2 200 3 300 4 100 9 200 8 300 7 I would liek to get O/P as 100 200 300 1 1 4 2 3 4 (8 Replies)
Discussion started by: Indra2011
8 Replies

8. Shell Programming and Scripting

Adding a timestamp every N row in another column

Hi, i have a raw output file like this 167,63.50 167,63.50 168,63.68 166,63.68 168,63.68 I would like to add every each N rows (for example 60) and in a third column , a timestamp using the command date +"%H:%M"how can i do it with one single command ? Thank you !! (5 Replies)
Discussion started by: Board27
5 Replies

9. Shell Programming and Scripting

Column to row and position data in a text file

Hi everyone.. I have a list of values in a file... a, b, c, 1, 2, 3, aaaa, bbbbb, I am interested in converting this column to a row.. "text",aaaa, bbbb a,1 (7 Replies)
Discussion started by: manihi
7 Replies

10. Shell Programming and Scripting

Print every alternate column in row in a text file

Hi, I have a comma separated file. I would like to print every alternate columns into a new row. Example input file: Name : John, Age : 30, DOB : 30-Oct-2018 Example output: Name,Age,DOB John,30,30-Oct-2018 (3 Replies)
Discussion started by: Lini
3 Replies
PadWalker(3)						User Contributed Perl Documentation					      PadWalker(3)

NAME
PadWalker - play with other peoples' lexical variables SYNOPSIS
use PadWalker qw(peek_my peek_our peek_sub closed_over); ... DESCRIPTION
PadWalker is a module which allows you to inspect (and even change!) lexical variables in any subroutine which called you. It will only show those variables which are in scope at the point of the call. PadWalker is particularly useful for debugging. It's even used by Perl's built-in debugger. (It can also be used for evil, of course.) I wouldn't recommend using PadWalker directly in production code, but it's your call. Some of the modules that use PadWalker internally are certainly safe for and useful in production. peek_my LEVEL peek_our LEVEL The LEVEL argument is interpreted just like the argument to "caller". So peek_my(0) returns a reference to a hash of all the "my" variables that are currently in scope; peek_my(1) returns a reference to a hash of all the "my" variables that are in scope at the point where the current sub was called, and so on. "peek_our" works in the same way, except that it lists the "our" variables rather than the "my" variables. The hash associates each variable name with a reference to its value. The variable names include the sigil, so the variable $x is represented by the string '$x'. For example: my $x = 12; my $h = peek_my (0); ${$h->{'$x'}}++; print $x; # prints 13 Or a more complex example: sub increment_my_x { my $h = peek_my (1); ${$h->{'$x'}}++; } my $x=5; increment_my_x; print $x; # prints 6 peek_sub SUB The "peek_sub" routine takes a coderef as its argument, and returns a hash of the "my" variables used in that sub. The values will usually be undefined unless the sub is in use (i.e. in the call-chain) at the time. On the other hand: my $x = "Hello!"; my $r = peek_sub(sub {$x})->{'$x'}; print "$$r "; # prints 'Hello!' If the sub defines several "my" variables with the same name, you'll get the last one. I don't know of any use for "peek_sub" that isn't broken as a result of this, and it will probably be deprecated in a future version in favour of some alternative interface. closed_over SUB "closed_over" is similar to "peek_sub", except that it only lists the "my" variables which are used in the subroutine but defined outside: in other words, the variables which it closes over. This does have reasonable uses: see Data::Dump::Streamer, for example (a future version of which may in fact use "closed_over"). set_closed_over SUB, HASH_REF "set_closed_over" reassigns the pad variables that are closed over by the subroutine. The second argument is a hash of references, much like the one returned from "closed_over". var_name LEVEL, VAR_REF var_name SUB, VAR_REF "var_name(sub, var_ref)" returns the name of the variable referred to by "var_ref", provided it is a "my" variable used in the sub. The "sub" parameter can be either a CODE reference or a number. If it's a number, it's treated the same way as the argument to "peek_my". For example, my $foo; print var_name(0, $foo); # prints '$foo' sub my_name { return var_name(1, shift); } print my_name($foo); # ditto AUTHOR
Robin Houston <robin@cpan.org> With contributions from Richard Soberberg, Jesse Luehrs and Yuval Kogman, bug-spotting from Peter Scott, Dave Mitchell and Goro Fuji, and suggestions from demerphq. SEE ALSO
Devel::LexAlias, Devel::Caller, Sub::Parameters COPYRIGHT
Copyright (c) 2000-2009, Robin Houston. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.16.2 2012-08-24 PadWalker(3)
All times are GMT -4. The time now is 01:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy