To make it easier, i gave following example. It is not homework or classwork. Instead, i have a huge csv file dump from tsql with 15 columns and around 300 rows. I was able to extract content that needs to be really converted. Here is the extract:
desire result should be:
based on sorting of field f4.
to make it simple, I created two files using grep for I and N but don't know how to append the third column if f1,f2 are same using comma as delim.
=========================
UNIX compare, sort lines and append difference
Hi,
Hi all
i am very new to shell scripting,hope u guys can help
i need to replace,sort and append character for the file that look like this:
1007032811010001000100000001X700026930409
1007032811010001000200000002X700026930409
1007032711020001000300000003X700026930409... (2 Replies)
I need to write a Shell Script to compare two files & display the result. If the two files are different append them and store them in a new file. How do i proceed...can someone give me a coding ? (3 Replies)
I have two files like this:
#FILE 1
ABCD 4322 26485
JMTJ 5311 97248
XMPJ 4321 58978
#FILE 2
ABCD 4321 26485
JMTJ 5311 97248
XMPJ 4321 68978
What to do: Compare the two files and find those lines that doesn't match. And have a new file like this:
#FILE 3
"from file 1"
ABCD 4322 26485... (11 Replies)
Hi,
I am using some codes that have been ported from unix to linux, and now the sorting no longer results in the desired ordering. I'm hoping to find a way to mimic the unix sort command in linux. The input file is structured the following:
$> cat file.txt... (6 Replies)
Hello all -
I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
I have output like this:
USER_ID
12/31/69 19:00:00
12/31/69 19:00:00
USER_ID
12/31/69 19:00:00
12/31/69 19:00:00
USER_ID
12/31/69 19:00:00
12/31/69 19:00:00
USER_ID
12/31/69 19:00:00
12/31/69 19:00:00
...
where USER_ID is a unique user login followed by their login timestamp and... (6 Replies)
To make it easier, i gave following example. It is not homework or classwork. Instead, i have a huge csv file dump from tsql with 15 columns and around 300 rows. I was able to extract content that needs to be really converted. Here is the extract:
ES FP,B1ES FP,70000,I,SL22,SL22 (70000)
ES... (8 Replies)
Hello,
I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Hi,
Could anyone kindly show me a link or explain the difference between
sort -n -k2 -k3 & sort -n -k2,3
Also, if I like to remove the row with repetition at both $2 and $3, Can I safely use
sort -u -k2 -k3
Example;
100 20 30
100 20 30
So, both $2 and $3 are same and I... (2 Replies)
Discussion started by: Indra2011
2 Replies
LEARN ABOUT MOJAVE
rs
RS(1) BSD General Commands Manual RS(1)NAME
rs -- reshape a data array
SYNOPSIS
rs [-[csCS][x] [kKgGw][N] tTeEnyjhHmz] [rows [cols]]
DESCRIPTION
The rs utility reads the standard input, interpreting each line as a row of blank-separated entries in an array, transforms the array accord-
ing 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 following options are available:
-cx Input columns are delimited by the single character x. A missing x is taken to be `^I'.
-sx Like -c, but maximal strings of x are delimiters.
-Cx Output columns are delimited by the single character x. A missing x is taken to be `^I'.
-Sx Like -C, but padded strings of x are delimiters.
-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.
-T Print the pure transpose of the input, ignoring any rows or cols specification.
-kN Ignore the first N lines of input.
-KN Like -k, but print the ignored lines.
-gN The gutter width (inter-column space), normally 2, is taken to be N.
-GN The gutter width has N percent of the maximum column width added to it.
-e Consider each line of input as an array entry.
-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.
-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.
-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.
-H Like -h, but also print the length of each line.
-j Right adjust entries within columns.
-wN The width of the display, normally 80, is taken to be the positive integer N.
-m Do not trim excess delimiters from the ends of the output array.
-z Adapt 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
The rs utility can be used as a filter to convert the stream output of certain programs (e.g., spell(1), du(1), file(1), look(1), nm(1),
who(1), and wc(1)) into a convenient ``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.
Multibyte characters are not recognized.
BSD July 30, 2004 BSD