Hi,
I have a bash script to ftp, sort and join two ascii files from another box,
then diff the resulting file with the equivalent file from yesterday.
However, the sort command seems to work differently when in the script,
compared to when I run the same series of commands at the bash prompt.
sort (GNU textutils) 2.0e
I even tried sorting the files twice, as when I sorted the already sorted file
at the command prompt, it changed the order.
Below are snippets from script and 'head' of files before and after sorting at
command prompt.
Any suggestions ?
Declan
snippet of script is :
-------------------------------------
#!/bin/sh
# Sort the 0118 file twice
sort dd_0118.tmp >dd_0118.tmp.sort1
sort dd_0118.tmp.sort1 >dd_sorted_0118.tmp
#Sort the 0120 file twice
sort dd_0120.tmp >dd_0120.tmp.sort1
sort dd_0120.tmp.sort1 >dd_sorted_0120.tmp
# Join the reulting files on field 1 from each file
join dd_sorted_0118.tmp dd_sorted_0120.tmp >dd_joined.tmp
#Get the differences between today and yesterday
diff dd_joined.tmp dd_joined.old >dd_joined.tmp2
-------------------------------------------
'head' of before and after sorting at command prompt.
[me at mail nuvotem]# head dd_sorted_0118.tmp
. DIA001 10061998
1 SCA001 09051995
2 HEW001 11101996
3 AVI001 11101996
4 THO001 11101996
5 RSC001 29092000
6 RSC001 29092000
7 STR001 29092000
8 STR001 29092000
9 AMV001 29092000
[me at mail nuvotem]# sort dd_sorted_0118.tmp >sort_again.tmp
[me at mail nuvotem]# head sort_again.tmp
10000 ISA001 08112001
10001 ISA001 08112001
10002 ICA001 09112001
10003 AMV001 31102001
10004 JPM001 09112001
10005 RSC001 09112001
10006 RSC001 09112001
10007 MAS001 09112001
10008 ISA001 09112001
10009 MJA001 09112001
[me at mail nuvotem]#
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!