Sponsored Content
Top Forums Shell Programming and Scripting Shell code for split/merge the file with certain number of columns Post 302899047 by SriniShoo on Friday 25th of April 2014 02:42:41 PM
Old 04-25-2014
The 2 examples you have given are different requirements
in the 1st, single record & field spanned across multiple lines
whereas in the 2nd, you have single record spanning across multiple lines and multiple records residing in single line
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

split a file into a specified number of files

I have been googling on the 'split' unix command to see if it can split a large file into 'n' number of files. Can anyone spare an example or a code snippet? Thanks, - CB (2 Replies)
Discussion started by: ChicagoBlues
2 Replies

2. Shell Programming and Scripting

Split File of Number with spaces

How do i split a variable of numbers with spaces... for example echo "100 100 100 100" > temp.txt as the values can always change in temp.txt, i think it will be feasible to split the numbers in accordance to column. How is it possible to make it into $a $b $c $d? (3 Replies)
Discussion started by: dplate07
3 Replies

3. Shell Programming and Scripting

Split file by number of words

Dear all I am trying to divide a file using the number of words as a condition. Alternatively, I would at least like to be able to retrieve the first x words of a given file. Any tips? Thanks in advance. (7 Replies)
Discussion started by: aavv
7 Replies

4. UNIX for Dummies Questions & Answers

How to split a huge file into small pieces (per 2000 columns)?

Dear all, I have a big file:2879(rows)x400,170 (columns) like below. I 'd like to split the file into small pieces:2879(rows)x2000(columns) per file (the last small piece will be 2879x170. So far, I only know how to create one samll piece at one time. But actually I need to repeat this work... (6 Replies)
Discussion started by: forevertl
6 Replies

5. Shell Programming and Scripting

file merge based on common columns

I have two files 1.txt 34, ABC, 7, 8, 0.9 35, CDE, 6.5, -2, 0.01 2.txt 34, ABC, 9, 6, -1.9 35, CDE, 8.5, -2.3, 5.01 So in both files common columns are 1 and 2 so final o/p should look like 34, ABC, 7, 8, 0.9, 9, 6, -1.9 35, CDE, 6.5, -2, 0.01, 8.5, -2.3, 5.01 I tried using... (3 Replies)
Discussion started by: manas_ranjan
3 Replies

6. Shell Programming and Scripting

Seperated by columns, merge in a file, sort them on common column

Hi All, I have 4 files in below format. I took them as an example. File 1: Cut from position 1-4 then 6-7 then 8-14 then rest left and make them as columns in one new file. Inserting character H to the initial of all line like HCTOT. CTOT 456787897 Low fever CTOR 556712345 High fever... (2 Replies)
Discussion started by: Mannu2525
2 Replies

7. Shell Programming and Scripting

Merge 2 last columns in a csv file using sed or perl

Hello everyone, want to merge 2 last columns 3rd and 4rd (if it exists). I have this 1;2;1;1 2;3;1;1 1;1;2 1;2;3;4 1;1;2 1;2;3;1 Desired output: 1;2;1 1 2;3;1 1 1;1;2 1;2;3 4 1;1;2 1;2;3 1 (3 Replies)
Discussion started by: satir
3 Replies

8. Shell Programming and Scripting

Split a non delimited file into columns depending on user input

I would like some advice on some code. I want to write a small script that will take an input file of this format 111222233334444555666661112222AAAA 2222333445556612323244455445454545 2334556345643534505435345353453453 (and so on) It will be called as : script inputfile X (where X is... (5 Replies)
Discussion started by: onlyforbopi
5 Replies

9. Shell Programming and Scripting

awk split columns to row after N number of column

I want to split this with every 5 or 50 depend on how much data the file will have. And remove the comma on the end Source file will have 001,0002,0003,004,005,0006,0007,007A,007B,007C,007E,007F,008A,008C Need Output from every 5 tab and remove the comma from end of each row ... (4 Replies)
Discussion started by: ranjancom2000
4 Replies

10. UNIX for Beginners Questions & Answers

Split into multiple files by using Unique columns in a UNIX file

I have requirement to split below file (sample.csv) into multiple files by using the unique columns (first 3 are unique columns) sample.csv 123|22|56789|ABCDEF|12AB34|2019-07-10|2019-07-10|443.3400|1|1 123|12|5679|BCDEFG|34CD56|2019-07-10|2019-07-10|896.7200|1|2... (3 Replies)
Discussion started by: RVSP
3 Replies
DBIx::Class::DynamicDefault(3pm)			User Contributed Perl Documentation			  DBIx::Class::DynamicDefault(3pm)

NAME
DBIx::Class::DynamicDefault - Automatically set and update fields SYNOPSIS
package My::Schema::SomeTable; __PACKAGE__->load_components(qw/DynamicDefault ... Core/); __PACKAGE__->add_columns( quux => { data_type => 'integer' }, quux_plus_one => { data_type => 'integer', dynamic_default_on_create => &quux_plus_one_default, dynamic_default_on_update => 'quux_plus_one_default', }, last_changed => { data_type => 'integer', dynamic_default_on_create => 'now', dynamic_default_on_update => 'now, }, ); sub quux_plus_one_default { my ($self) = @_; return $self->quux + 1; } sub now { return DateTime->now->epoch; } Now, any update or create actions will set the specified columns to the value returned by the callback you specified as a method name or code reference. DESCRIPTION
Automatically set and update fields with values calculated at runtime. OPTIONS
dynamic_default_on_create dynamic_default_on_create => sub { ... } dynamic_default_on_create => 'method_name' When inserting a new row all columns with the "dynamic_default_on_create" option will be set to the return value of the specified callback unless the columns value has been explicitly set. The callback, that'll be invoked with the row object as its only argument, may be a code reference or a method name. dynamic_default_on_update dynamic_default_on_update => sub { ... } dynamic_default_on_update => 'method_name' When updating a row all columns with the "dynamic_default_on_update" option will be set to the return value of the specified callback unless the columns value has been explicitly set. Columns will only be altered if other dirty columns exist. See "always_update" on how to change this. always_update always_update => 1 When setting "always_update" to 1 "dynamic_default_on_update" callbacks will always be invoked, even if no other columns are dirty. AUTHOR
Florian Ragwitz <rafl@debian.org> LICENSE
This software is copyright (c) 2008 by Florian Ragwitz. This is free software; you can redistribute it and/or modify it under the same terms as perl itself. perl v5.14.2 2012-04-14 DBIx::Class::DynamicDefault(3pm)
All times are GMT -4. The time now is 08:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy