Help me to resolve uncertian behaviour of a sort command
I have got a file BeforeSort.txt having 40 fields seperated by "|"
First field= RecordType (Value will be P or FP)
Second field= CamCode
Third field = UpdatingDate
Fourth field = ProductType
Fifth field = ActionCode (Value may be 01, 02 or 03)
Sixth field = ProductCode
and so on
My requirement is that to sort the above file to get unique records based on Second, Fourth and Sixth fields AND also
(1) If there are multiple records for above 3 key fields and with first field RecordType P and FP then take only P record
(2) If there are multiple records for above 3 key fields and with first field RecordType P only then take only P record
(3) If there are multiple records for above 3 key fields and with first field RecordType FP only then take only FP record
I used following sort command to get required records as above :
sort -ur -t "|" -k 2,2 -k 4,4 -k 6,6 BeforeSort.txt > AfterSort.txt
(I am attaching file BeforeSort.txt herewith)
This command is working fine for this small file.
==============
Now the actual problem :
But when I executed the above command for a real big file PRinLG90_PFP and redirecting the output in file PRinLG90_PFPSort. Then this output file contains some unexpected record for some of ProductCodes.
(I have attached file PRinLG90_PFP.txt in zip file PRinLG90_PFP.zip)
(1) For sixth field ProductCode R5V2*L503BB6 there are two records with first field RecordType = P & FP and fourth field CamCode = 0049 in file PRinLG90_PFP. And in file PRinLG90_PFPSort there is record of first field RecordType = P
(Which is the required and right output record).
(2)But for sixth field ProductCode R8V2*L503BB6 there are two records with first field RecordType = P & FP and fourth field CamCode = 0049 in file PRinLG90_PFP. But in file PRinLG90_PFPSort there is record of first field RecordType = FP
(While our requirement is that ,it should be P record instead of FP record)
I could not understand the above different behaviour of this used sort command.
could I take your expert help on this to know the reason/action of this uncertain behaviour of this above sort command.
Please help me, because this command is to be used to send a very important and urget delivery
Hi guys,
I have the following example data:
A;00:00:19
B;00:01:02
C;00:00:13
D;00:00:16
E;00:02:27
F;00:00:12
G;00:00:21
H;00:00:19
I;00:00:13
J;00:13:22
I run the following sort against it, yet the output is as follows:
sort -t";" +1 -nr example_data.dat
A;00:00:19 (16 Replies)
Hi
Don't know if this is a dummy question, but let's give it a try.
I yesterday had a problem with undefined behaviour in the sort shell command (I'm using bash), leading to different sort orders without apparent reasons. I resolved this by typing
export LC_ALL="C"
export LC_COLLATE="C"... (5 Replies)
Hi to all.
I'm trying to sort this with the Unix command sort.
user1:12345678:3.5:2.5:8:1:2:3
user2:12345679:4.5:3.5:8:1:3:2
user3:12345687:5.5:2.5:6:1:3:2
user4:12345670:5.5:2.5:5:3:2:1
user5:12345671:2.5:5.5:7:2:3:1
I need to get this:
user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
I am running a program written in perl script and it is stopped with "Out of memory!" error. This is very strange because at the time then the program is aborted, it only used 4GB RAM and there are still 30GB free physical memory left in the system. I check the perl script and found the program... (3 Replies)
Hello All,
I came across this line in a shell script that I was looking at yesterday. Couldn't get a clue of what it does. :confused:
....
....
blah blah
....
.....
exec >&- 2>&-
......
blah blah
.....
Can someone explain me this??
Usually I have seen exec commands used to... (3 Replies)
I have a script as below.
bash-3.00$ cat test.sh
#!/usr/bin/ksh
path=`pwd`
echo $path
var=$path/temp11
echo $var
If run it is giving output
bash-3.00$ ksh test.sh
//var/tmp/SB2/miscellaneous
//var/tmp/SB2/miscellaneous/temp11 (5 Replies)
I see strange results when sorting with -n options and I wander if somebody can explain it.
Input file and two results:
$ cat aa
14
-1
11
-1
0
-1
0
$ sort -u aa
-1
0 (1 Reply)
Hi Experts,
ps command behavior in Redhat is such that it outputs all the output(of long lengths). In Unix the ps command output was limited to only 80 chars. In that if you pipe its output to another command hen the 80 chars restriction wouldn't be there. This 80 char limitation will only be... (14 Replies)