Figure out complex sort


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Figure out complex sort
# 8  
Old 02-05-2009
Quote:
Originally Posted by w020637
Code:
#!/bin/ksh
##########################################
#Directories
eagle_dir=/test
#Imp Files
FILENAME=/test/files.txt
usage(){
        print process_test.sh - script to process test data
        print "Usage: process_test.sh"


print is non-standard and doesn't offer anything over standard commands.

If you use only standard commands, you can easily move your script to another shell if there's some feature you need that's not in ksh,

Code:
 printf "%s\n" "process_test.sh - script to process test data"
 printf "%s\n" "Usage: process_test.sh"

Quote:
Code:
        }
cat $FILENAME | while read LINE


There's no need for cat:

Code:
while IFS= read -r LINE
do
  : ....
done < "$FILENAME"

Quote:
Code:
do
  ls -r1 "$test"/"$LINE"_????????_??????_??????.txt|sort -t2 +1 -r|head -1|while read obj


Why all those quotation marks?

Code:
  ls -r1 "$test/$LINE"_????????_??????_??????.txt |

Quote:
Code:
  do
    echo "Inside DO $LINE loop"
    echo  $obj
  done
done
# end script

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with change significant figure to normal figure command

Hi, Below is my input file: Long list of significant figure 1.757E-4 7.51E-3 5.634E-5 . . . Desired output file: 0.0001757 0.00751 0.00005634 . . . (10 Replies)
Discussion started by: perl_beginner
10 Replies

2. Shell Programming and Scripting

How to sort by complex algorithm

Hello, To simplify ma question, here is my list : # cat liste a m x h and here is the right order to list his component : liste_order="1:m 2:a 3:h 4:x" The only way to sort my file like I want, I find this idea : cat liste | sed 's/a/2:a/g' | sed 's/m/1:m/g' | sed... (9 Replies)
Discussion started by: mlaiti
9 Replies

3. UNIX for Dummies Questions & Answers

Can't figure this one out --

I'm putting together a shell script while I'm learning UNIX -- just for myself. It's a little script that simply takes some vendor names and writes them to a file. So far I'm at the stage where the user enters the name of the file and places it in a folder called vendorlists: * ) touch... (5 Replies)
Discussion started by: Straitsfan
5 Replies

4. UNIX for Advanced & Expert Users

Can't figure out how this is working

I have two machines, each with a virtual interface, with the following configurations: Machine1: eth2 Link encap:Ethernet HWaddr 00:09:6B:19:E5:05 inet addr:172.16.0.201 Bcast:172.16.0.255 Mask:255.255.255.0 eth2:0 Link encap:Ethernet HWaddr 00:09:6B:19:E5:05 ... (0 Replies)
Discussion started by: druidmatrix
0 Replies

5. UNIX for Dummies Questions & Answers

Sort directory with complex numeric file names

I have a directory with a large number (1000s) of files and I need to produce a file listing all the files in the directory ordered "properly" (properly will be explained shortly). The files have the following naming pattern: bul_13_5_228_b.txt bul_1_3_57.txt bul_13_6_229.txt... (2 Replies)
Discussion started by: fdsayre
2 Replies

6. IP Networking

How do I figure out the subnet?

Hi, How do I get subnet from this: 10.252.0.138/25 Tnx (2 Replies)
Discussion started by: mehrdad68
2 Replies

7. Shell Programming and Scripting

Sort complex data

Hi, Can someone here help sorting the following data in numeric order? INPUT: FIRST abc(3) def(13) fgh(1) ijk(6) abc(2) SECOND dfe(10) abc(4) hij(19) tlm(1) hij(1) hub(10) abc(1) fed(3) OTHERS hij(10) mok(4) bub(19) hij(1) abc(2) abc(15) abc(1) hij(3) OUTPUT: FIRST def(13) ijk(6)... (12 Replies)
Discussion started by: need_help
12 Replies

8. Shell Programming and Scripting

Cant figure out this..

Hi, I need a little help here. I am exporting user info from a PSQL database and everything is working with the exception of this: 10029008:dsAuthMethodStandard\:dsAuthClearText:classword:10029008:2004:10029008:10029008:/home/student/1002/90/08:10029008 It is putting a colon right before the... (1 Reply)
Discussion started by: Stud33
1 Replies

9. UNIX for Dummies Questions & Answers

figure it out

hi there i am new to this site and this linux and unix stuff so kind of plz help me out hoe to start the stuff.... (1 Reply)
Discussion started by: cool_dude
1 Replies

10. UNIX for Dummies Questions & Answers

i can not figure this out

I am having problems scripting in UNIX. I am currently attending school and for the first time I am being introduced to scripting. My problem is I am supposed to enhance the spell_check by adding a third optional argument. The third argument is to specify a list of words to be added to the... (1 Reply)
Discussion started by: steph
1 Replies
Login or Register to Ask a Question