Sponsored Content
Full Discussion: Sorting rows to columns
Top Forums UNIX for Dummies Questions & Answers Sorting rows to columns Post 302779699 by pamu on Wednesday 13th of March 2013 08:48:05 AM
Old 03-13-2013
Quote:
Originally Posted by AAWT
Hi Pamu,
I gave this command in cygwin,
Code:
 awk '{for(i=1;i<=length($2);i+=7){print $1,substr($2,i,7)}}'AT.txt > ATTT.txt

and got, SYNTEX ERROR line 1

waiting for help

Regards
Please give space between awk and filename.

try with..

Code:
awk '{for(i=1;i<=length($2);i+=7){print $1,substr($2,i,7)}}' AT.txt > ATTT.txt

This User Gave Thanks to pamu For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting based on columns

Hi, I want a list of entries in 3 space delimited columns. I want to sort entries based on the very first column. Rows can't be changed. For example: If I have... Abc Abc Acc Bca Bda Bdd Cab Cab Cbc Dbc Dca Dda Abc Abc Acc the output should be... Abc Abc Acc Abc Abc Acc Bca... (7 Replies)
Discussion started by: MobileUser
7 Replies

2. UNIX for Advanced & Expert Users

sorting of varchar columns

Hi , I need to sort a file based on multiple columns All the columns are of varchar type can any one give me the command to sort for varchar columns? Thanks (3 Replies)
Discussion started by: laxmi131
3 Replies

3. UNIX for Dummies Questions & Answers

Vertical sorting of columns

Please help to sort columns in this file: a b d f c e 1 4 10 16 7 13 2 5 11 17 8 14 3 6 12 18 9 15 I need to sort COLUMNS (so sort command doesn't work) like this: a b c d e f 1 4 7 10 13 16 2 5 8 11 14 17 3 6 9 12 15 18 I know sed can do it but don't know how... :( (7 Replies)
Discussion started by: coppuca
7 Replies

4. Shell Programming and Scripting

sorting and adding columns

i have a file with two columns, and i want to uniquely sort the values in fist column and add the corresponding values in the second columns eg file a contents tom 200 john 300 sow 500 tom 800 james 50 sow 300 output shpould be in file b as tom 1000 john 300 sow 800 james 50 (0 Replies)
Discussion started by: dealerso
0 Replies

5. Shell Programming and Scripting

Help in sorting multiple columns

Hello all, I am using printf to print the sorted o/p in my script.I am trying to sort in following way but doesn't work. printf "%13s %2s UDP %15s:%s Program %4s HD: %23s HD: %23s %10s %s %s %3s days %3s hours\n" $encoder $i "${ipaddr}" ${portno} ${progno} ${inres} ${outres} ${inrate}... (4 Replies)
Discussion started by: ramman
4 Replies

6. Shell Programming and Scripting

Kindly Help regarding sorting a file rows

Dear All, I have a file name exporting.txt. Below is the content. $ cat exporting.txt . . exporting table DT_BCD 63716 rows exported . . exporting table DT_CVD 36321 ... (2 Replies)
Discussion started by: sudiptabhaskar
2 Replies

7. Shell Programming and Scripting

Deleting all the fields(columns) from a .csv file if all rows in that columns are blanks

Hi Friends, I have come across some files where some of the columns don not have data. Key, Data1,Data2,Data3,Data4,Data5 A,5,6,,10,, A,3,4,,3,, B,1,,4,5,, B,2,,3,4,, If we see the above data on Data5 column do not have any row got filled. So remove only that column(Here Data5) and... (4 Replies)
Discussion started by: ks_reddy
4 Replies

8. Shell Programming and Scripting

Evaluate 2 columns, add sum IF two columns match on two rows

Hi all, I know this sounds suspiciously like a homework course; but, it is not. My goal is to take a file, and match my "ID" column to the "Date" column, if those conditions are true, add the total number of minutes worked and place it in this file, while not printing the original rows that I... (6 Replies)
Discussion started by: mtucker6784
6 Replies

9. Shell Programming and Scripting

Sorting by columns

Hi, I have a tab delimited columnar file where I want to remove lines wherever two particular columns match. so for this file, I want to toss the lines where columns 1 and 2 match: a a 1 3 a b 2 4 b b 3 5 because there are matches column 1 and 2 in lines 1 and 3, I would like a script to... (2 Replies)
Discussion started by: mikey11415
2 Replies

10. Shell Programming and Scripting

Compare 2 csv files by columns, then extract certain columns of matcing rows

Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns. I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies
RS(1)							    BSD General Commands Manual 						     RS(1)

NAME
rs -- reshape a data array SYNOPSIS
rs [-CcSs[x]] [-GgKkw N] [-EeHhjmnTtyz] [rows [cols]] DESCRIPTION
rs reads the standard input, interpreting each line as a row of blank-separated entries in an array, transforms the array according to the options, and writes it on the standard output. With no arguments it transforms stream input into a columnar format convenient for terminal viewing. The shape of the input array is deduced from the number of lines and the number of columns on the first line. If that shape is inconvenient, a more useful one might be obtained by skipping some of the input with the -k option. Other options control interpretation of the input col- umns. The shape of the output array is influenced by the rows and cols specifications, which should be positive integers. If only one of them is a positive integer, rs computes a value for the other which will accommodate all of the data. When necessary, missing data are supplied in a manner specified by the options and surplus data are deleted. There are options to control presentation of the output columns, including transposition of the rows and columns. The options are as follows: -C[x] Output columns are delimited by the single character x. A missing x is taken to be '^I'. -c[x] Input columns are delimited by the single character x. A missing x is taken to be '^I'. -E Consider each character of input as an array entry. -e Consider each line of input as an array entry. -GN The gutter width has N percent of the maximum column width added to it. -gN The gutter width (inter-column space), normally 2, is taken to be N. -H Like -h, but also print the length of each line. -h Print the shape of the input array and do nothing else. The shape is just the number of lines and the number of entries on the first line. -j Right adjust entries within columns. -KN Like -k, but print the ignored lines. -kN Ignore the first N lines of input. -m Do not trim excess delimiters from the ends of the output array. -n On lines having fewer entries than the first line, use null entries to pad out the line. Normally, missing entries are taken from the next line of input. -S[x] Like -C, but padded strings of x are delimiters. -s[x] Like -c, but maximal strings of x are delimiters. -T Print the pure transpose of the input, ignoring any rows or cols specification. -t Fill in the rows of the output array using the columns of the input array, that is, transpose the input while honoring any rows and cols specifications. -wN The width of the display, normally 80, is taken to be the positive integer N. -y If there are too few entries to make up the output dimensions, pad the output by recycling the input from the beginning. Normally, the output is padded with blanks. -z Shrink column widths to fit the largest entries appearing in them. With no arguments, rs transposes its input, and assumes one array entry per input line unless the first non-ignored line is longer than the display width. Option letters which take numerical arguments interpret a missing number as zero unless otherwise indicated. EXAMPLES
rs can be used as a filter to convert the stream output of certain programs (e.g., spell, du, file, look, nm, who, and wc(1)) into a conve- nient ``window'' format, as in $ who | rs This function has been incorporated into the ls(1) program, though for most programs with similar output rs suffices. To convert stream input into vector output and back again, use $ rs 1 0 | rs 0 1 A 10 by 10 array of random numbers from 1 to 100 and its transpose can be generated with $ jot -r 100 | rs 10 10 | tee array | rs -T >tarray In the editor vi(1), a file consisting of a multi-line vector with 9 elements per line can undergo insertions and deletions, and then be neatly reshaped into 9 columns with :1,$!rs 0 9 Finally, to sort a database by the first line of each 4-line field, try $ rs -eC 0 4 | sort | rs -c 0 1 SEE ALSO
jot(1), pr(1), sort(1), vi(1) BUGS
Handles only two dimensional arrays. The algorithm currently reads the whole file into memory, so files that do not fit in memory will not be reshaped. Fields cannot be defined yet on character positions. Re-ordering of columns is not yet possible. There are too many options. BSD
April 14, 2012 BSD
All times are GMT -4. The time now is 12:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy