sort shell?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sort shell?
# 1  
Old 11-25-2010
sort shell?

hello my problem is that I have to do diferents sorts shells with diferents logical algorithms
like shell sort, select sort, quick sort and bubble sort.
starting from a basic shell that says something like:

file = cat $1
sortLogic = $2
colSort = $3
source sortLogic file colSort > $4

this basic shell receives the file that I want to order, sort shell, the column being sorted, and the file where the sorted file was printed.

I get (understand) the sorts algorithms logic
the problem is I dont know how to do the sort shells
receiving a file as a parameter and the column to sort

I thought of the solution by awk but I dont know how to build the script
I need whiles or fors to read from column 1 to column n
where n is a decreasing variable and does the same with rows

And also make comparisons of data in columns
and that it would replace. but again I dont know how to do this.

I did try to get as example the /bin/sort, but It encrypted (on my pc)...
I realy appreciate your help ar recommendations.
# 2  
Old 11-25-2010
We have a homework forum - and this post is clearly homework. Please repost there.


Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to sort a content of a text file using a shell script?

I am new to shell scripting. I am interested how to know how to sort a content of a file using shell scripting. I've attached the 'Input file' and the 'expected output' to this thread. Details provided in the expected output file will provide details on how the sort needs to be done. ... (16 Replies)
Discussion started by: nkarthik_mnnit
16 Replies

2. Shell Programming and Scripting

How to sort the timestamp in the filename in shell script?

originally the shellscript #ln_file_name=`echo $ld_interface_date"_"${8}".csv"` #ln_file_name=`echo 201202011527_HL_HLTM1_B04A.csv` ln_file_name="*"`echo ${7}".csv"` get_file_list_1=$log_path"tm1_file_list.gfl1" cd ${source_path} echo "Try to find any file exist in the... (10 Replies)
Discussion started by: feilhk
10 Replies

3. Homework & Coursework Questions

Shell script/awk to sort text

1. The problem statement, all variables and given/known data: I have a file with a fragment of a novel, which I have to clear from punctuation and sort all the words contained one per line and non duplicated, all this going to a file called "palabras". Here is fragment of the input file: ... (4 Replies)
Discussion started by: ektorzoza
4 Replies

4. Shell Programming and Scripting

shell script to sort information in one file

Hi to all, anyway to create shell script to sort informations from one file and create new file with the sorted values? from file 30days.out -bash-3.00# more 30days.out user/str4@kl.com/INBOX user/tg1@johor.com/INBOX user/tg2@kedah.com/INBOX user/tg3@titangroup.com/INBOX... (3 Replies)
Discussion started by: Mr_47
3 Replies

5. Shell Programming and Scripting

sort shell

Hello, reéaliser I'd like a program that sorts the entries in a directory under different options: -R: Sorting the contents of the directory tree starting at pos. In this case we will sort with respect to the names of the entries but it will show the path; -D: sort in descending order by... (1 Reply)
Discussion started by: yaya125
1 Replies

6. Shell Programming and Scripting

shell script to sort the 5th column

hi folks, I have this data in a data.txt file and i want to sort the 5th column and in descending order: Jun 15 119.167.247.40 = 23 Jun 15 119.167.247.40 = 3 Jun 15 208.115.46.125 = 12 Jun 15 208.115.46.125 = 6 Jun 15 210.51.10.160 = 20 I want this sample output: Jun... (2 Replies)
Discussion started by: linuxgeek
2 Replies

7. UNIX for Dummies Questions & Answers

shell: reconcile language and sort behaviour

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)
Discussion started by: jossojjos
5 Replies

8. Shell Programming and Scripting

how to get some sort of graphics using shell scripts?

Hi all, I would like to know how to have graphics embedded using shell scripts... I mean simple =========> or ---------> would do... The main idea here is for every element of the bar to move for every % completion of data..... I tried echo under a for loop ,but it was not giving me o/p that... (3 Replies)
Discussion started by: wrapster
3 Replies

9. Shell Programming and Scripting

Unable to use sort command in Shell Script

Hello All, I am creating a shell script that reads a file(test.txt) with the following data, 0.0.0.0 10.10.10.0 10.10.10.1 10.10.10.10 10.10.10.2 10.10.10.3 10.10.10.4 10.10.10.5 10.10.10.6 10.10.10.7 10.10.10.8 10.10.10.9 If I use the sort, the highest value I am getting is... (1 Reply)
Discussion started by: racbern
1 Replies

10. Programming

comb/shell sort

Hi all, Can someone explain to me how shell sort works and tell me why it can not be used on linked lists. Thanks (8 Replies)
Discussion started by: newbietoIT
8 Replies
Login or Register to Ask a Question