Display combination of 4 field uniqe record and along with concatenate 5th and 6th field.
Table
i have written shell script using cut command
and awk programming getting error correct it and add header we can use echo for header is it other way display the header
Please ignore space consider | separtor
below output should be display
First 4 filed will be display unique and last two field should be concatenate(no1)$(no2)
Appreciate ur replay
Last edited by Corona688; 10-16-2015 at 08:01 PM..
Table
i have written shell script using cut command
and awk programming getting error correct it and add header we can use echo for header is it other way display the header
Please ignore space consider | separtor
below output should be display
First 4 filed will be display unique and last two field should be concatenate(no1)$(no2)
Appreciate ur replay
There are some strange things in your scripts that don't seem to match your stated requirements:
Your shell script works on 6 variables per line; your awk script works on 5 variables per line.
Your shell script gathers the input from field #5 into a variable named no1 and then overwrites that variable with the input gathered from field #6.
Neither script handles field separators consistently and the echo in your shell script is adding unwanted spaces.
You talk about using echo to add a header, but neither script does that and your desired output does not show any header.
I don't understand why you name your awk arrays MIN[] and MAX[] when the next to the last line in your sample input has MIN[IX]=25 < MAX[IX]=20.
And, I don't understand why you use a file named test as the input file for your shell script and a file named file as the input for your awk script.
Assuming that your input file is named file and that you do want to keep the header that appears on the first line in your input file, you could try something like:
which, with the sample input you provided, produces the output:
As always, if you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
Note that invoking awk once to process the entire input file contents instead of invoking cut six times for each line in the input file multiplied by the number of different values of the 1st field in the file and once more, invoking cat one plus the number of different values of the 1st field times, invoking uniq once, and invoking sed once obviously makes using awk MUCH faster and more efficient than using the shell script as it is currently written. Note, however, that the shell script could also be rewritten without invoking cat, cut, sed, or grep just using one or two while read loops perhaps with one invocation of sort or uniq.
If 2 extra fields $7(SUM1) and $8(SUM2) is there how can we will
Display combination of 4 field unique record and along with concatenate 5th and 6th field and summations of 7 and 8 fields
Bash Shell/Oracle Linux 6.4
Following is an ls -lh output. Files which are equal to or higher than 1Gigabytes will displayed with G in the 5th column of the output.
I am trying to find all files which are equal to or higher than 1G
File sizes are shown in the 5th column. So, I tried cut -d'... (7 Replies)
Thank you for 4 looking this post.
We have a tab delimited file where we are facing problem in a lot of funny character. I have tried using awk but failed that is not working.
In the 5th field ID which is supposed to be a integer only of that file, we are getting corrupted data as below.
I... (12 Replies)
Here's a sample of the data:
NAME BIRTHDAY SEX LOCATION AGE ID
Jim 05/11/1986 M Japan 27 86
Rei 08/25/1990 F Korea 24 33
Jane 02/24/1985 F India 29 78
I've been trying to sort files using the... (8 Replies)
Hello all,
Maybe you can help me with an awk script to get what I need.
I have the input file with format below:
REQUEST|79023787741690|738227864597|985
REQUEST|79024002151717|738229423534|985
REQUEST|79024002151717|738229423534|*985
NDS-REQUEST|79024002151717|738229423534
... (4 Replies)
i have file A as below contents
---------------------------
Use descriptive thread titles when posting.
For example, do not post questions with subjects like
"Help Me!", "Urgent!!" or "Doubt".
For example, do not post questions
For example, do not deliminated.
output file as below:... (2 Replies)
Hi,
I have a file like this
A Bob
A Sam
A John
B David
C Paul
C Sandra
If the consecutive field values in column one is same, then concatenate the corresponding strings.
So, I need an output like this,
A Bob_Sam_John
B David
C Paul_Sandra
I usually work with excel but... (3 Replies)
Hi,
I have a huge text file. It looks like
abcde bangalo country 12345 lastfield
i want to get first 3 characters from field1 and first 3 characters from field 2 and insert the result as a new field. example the result should be:
abcde bangalo abcban country 12345 lastfield
Please... (4 Replies)
I have a file as:
A,B,C,D,E
G,H,I,J,K
I need to find if fourth field is blank or has a space and print that line to other file.
I tried using awk but am not getting the desired result.
Pls help. (6 Replies)
I have a script which retrieves certain fields from a text file using awk. The delimiter used is white space.
cat /home/eis/boss/OPS|while read LINE
do
crdno=`echo $LINE | awk '{print $1}'`
atm=`echo $LINE | awk '{print $2}'`
seq=`echo $LINE | awk '{print $3}'`
amount=`echo $LINE | awk... (3 Replies)