Sponsored Content
Top Forums Shell Programming and Scripting Help - manipulate data by columns and repeated Post 302977554 by rdrtx1 on Tuesday 19th of July 2016 04:38:45 PM
Old 07-19-2016
Code:
infile=Dato01.txt
outfile=Dato02.txt

[[ ! -f $infile.bk ]] && cp $infile $infile.bk

ex $infile <<EDIT
$(awk '
  NR==1 {print ":" NR " w " outfile; next;}
  {if (a[$1]++) r[c++]=NR}
  END {
     for (i=0; i<c; i++) print ":" r[i] " w >> " outfile;
     for (i=c-1; i>=0; i--) print ":" r[i] " d";
     print ":wq!";
  }
' outfile=$outfile $infile)
EDIT

This User Gave Thanks to rdrtx1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

manipulate csv file to add columns

Hi, I have a csv file with a key composed by 3 columns and some other numeric fields and I need to obtain the partial amounts by some part of the key. This may be some difficult to understand, so better see an example, where my input file is: name,surname,department,y2004,y2005,y2006... (6 Replies)
Discussion started by: oscarmon
6 Replies

2. UNIX for Dummies Questions & Answers

Excel data manipulate

All, I have the following format of data in a spreadsheet A 1 2 3 4 B 1 2 3 4 where 'A' is value of 'A1', '1 2 3 4' is value of cell B1, 'B' is value of cell A2, and '1 2 3 4' is value of cell B2. There... (12 Replies)
Discussion started by: rahulrathod
12 Replies

3. Shell Programming and Scripting

comparing the values of repeated keys in multiple columns

Hi Guyz The 1st column of the input file has repeated keys like x,y and z. The ist task is if the 1st column has unique key (say x) and then need to consider 4th column, if it is + symbol then subtract 2nd column value with 3rd column value (we will get 2(10-8)) or if it is - symbol subtract 3rd... (3 Replies)
Discussion started by: repinementer
3 Replies

4. Shell Programming and Scripting

how to manipulate with lines while playing with data

hello everyone, well I have a file which contains data, I want to add the data on hourly basis, like my file contains data for 24 hours, (so a total of 1440 ) lines. Now i want to add the data on hourly basis to get average values. like if I use (head) command it is ok for first go, but... (5 Replies)
Discussion started by: jojo123
5 Replies

5. Shell Programming and Scripting

Converted repeated rows into splitted columns

Dear Friends, I have an input file contains lot of datas, which is like repaeated rows report. The output file need to have column wise report, rather than row-wise. Input File random line 1 random line 2 random line 3 ------------------------------------- Start line 1.1 (9.9) ... (1 Reply)
Discussion started by: vasanth.vadalur
1 Replies

6. Shell Programming and Scripting

Manipulate columns using sed

Hello, I would like to remove the first column of lines beginning by a character (in my case is an open square bracket) and finishing by a space (or any other delimiter). For example: string1 string2 string3 to string2 string3 I found this previous topic: ... (1 Reply)
Discussion started by: stoyanova
1 Replies

7. UNIX for Dummies Questions & Answers

Manipulate and move columns in a file

Hello Unix Gurus, I have a request 2 perform several functions on a file, delete columns, delete rows based on column value, and finally move around columns in the final output. Consider the following input file with 12 columns; ... (1 Reply)
Discussion started by: chumsky
1 Replies

8. Shell Programming and Scripting

Transposing Repeated Rows to Columns.

I have 1000s of these rows that I would like to transpose to columns. However I would like the transpose every 3 consecutive rows to columns like below, sorted by column 3 and provide a total for each occurrences. Finally I would like a grand total of column 3. 21|FE|41|0B 50\65\78 15... (2 Replies)
Discussion started by: ravzter
2 Replies

9. Shell Programming and Scripting

Need help to manipulate data using script

Hi i want to manipulate my data to convert row to column name 600 Slno vlan 1 600 2 609 3 700 name 700 Slno vlan 1 600 2 609 3 700 (8 Replies)
Discussion started by: nith_anandan
8 Replies

10. Shell Programming and Scripting

Manipulate the columns of 2 files

Hello, I have two files to be treated. First file: col1 col2 col3 col4 Second file: colbis - I try to add the unique column of the file 2 towards the file 1. - To obtain the following result with a shell script ksh: col1 col2 col3 col4 colbis (4 Replies)
Discussion started by: khalidou13
4 Replies
Internals(3)						User Contributed Perl Documentation					      Internals(3)

NAME
Internals - Write-protect variables, manipulate refcounts SYNOPSIS
use Internals qw(IsWriteProtected SetReadOnly SetReadWrite GetRefCount SetRefCount); use Internals qw(:all); $object = My::Class->new(@parameters); SetReadOnly($object); SetReadWrite($object); if (IsWriteProtected($object)) { ... } $value = GetRefCount($object); SetRefCount($object,$value); or package My::Class; use Internals; @ISA = qw(Internals); $object = My::Class->new(@parameters)->SetReadOnly(); $object->SetReadWrite(); if ($object->IsWriteProtected()) { ... } $value = $object->GetRefCount(); $object->SetRefCount($value); or use Internals qw(IsWriteProtected SetReadOnly SetReadWrite GetRefCount SetRefCount); use Internals qw(:all); SetReadOnly($scalar); SetReadOnly(@array); SetReadOnly(\%hash); SetReadOnly($hash{$element}); SetReadOnly($reference); etc. DESCRIPTION
This module allows you to write-protect and write-enable your Perl variables, objects and data structures. Moreover, the reference count of any Perl variable can be read and set. You can never pass the object directly on which to perform the desired action, you always have to pass a reference to the variable or data structure in question. This comes in handy for objects and anonymous data structures, where you only have a reference anyway! BEWARE: This module is DANGEROUS! DO NOT attempt to unlock Perl's built-in variables! DO NOT manipulate reference counts unless you know exactly what you're doing! ANYTHING might happen! Hell might break loose! ":-)" YOU HAVE BEEN WARNED! VERSION
This man page documents "Internals" version 1.1. AUTHOR
Steffen Beyer mailto:sb@engelschall.com http://www.engelschall.com/u/sb/download/ COPYRIGHT
Copyright (c) 2001 by Steffen Beyer. All rights reserved. LICENSE
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License". Please refer to the files "Artistic.txt" and "GNU_GPL.txt" in this distribution for details! DISCLAIMER
This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "GNU General Public License" for more details. perl v5.16.2 2001-09-30 Internals(3)
All times are GMT -4. The time now is 01:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy