sort script/command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sort script/command
# 1  
Old 11-15-2005
sort script/command

ok.

i am doing a project where i have hand typed in the titles of nearly 500 DVD titles, each one is on a seperate line.
but they arent in any type of alphebetical order, and i need them sorted in that format (A-Z or a-z) .....

i know that the 'sort' command can be used but also know the output is gonna come out all wacky due to titles that start with 'the' or 'a' .

if ANYONE could help i really appreciate it a lot.
# 2  
Old 11-15-2005
I´ve tried it on Solaris 9 with no problems , with a no-option sort:

root@nbu-sol-1 # cat dvds
the whatever story
a day in Someone`s life
another dvd title
Starting with Starting


root@nbu-sol-1 # cat dvds | sort
Starting with Starting
a day in Someone`s life
another dvd title
the whatever story
# 3  
Old 11-15-2005
with that i created a nice script, you will notice the scripts i make for the most part are rather 'user friendly'

Code:
 # This Script created by Chad Cope on 11/15/2005
 # Please Feel Free to place this on any system
 # you want, but keep this header intact. -Chad C.

 echo "Welcome to the file sorter, What Should I call you?"
 read name
 echo " "
 echo "Okay, $name ..."   "what is the name of the file you"
 echo "want to sort out?"  "type ONLY the files NAME"
 sleep 1
 read file
 echo " "
 echo "okay $name the file you are about to sort is called $file"
 echo "please give me a second to sort it out for you"
 echo "right now this will show you your list, re-arranged"
 echo "And then it will place it into a file all sorted out."
 sleep 1
 echo " "
 echo "What do you want the new file name to be?"
 echo "NEW FILENAME SHOULD NOT BE THE SAME AS '$file' "
 read newfile
 echo " "
 echo "SORTING $file NOW!"
 sleep 2
 echo " "
 cat $file | sort
 echo " "
 echo "now creating new file: $newfile "
 cat $file | sort > $newfile
 echo " "
 echo "Thats your list all sorted out $name"  "ENJOY!!!"
 echo "Your new file has also been created with the file name"
 echo "that you have choosen; $newfile "  "and will now be"
 echo "chmoded as chmod 744" "so others can see it"
 chmod 744 $newfile
 sleep 4
 echo "You may notice that any titles starting with 'the' or 'a' "
 echo "will get thrown into the 'T' or 'A' catagory..."
 sleep 1
 echo "I suggest you create a file like this to help sort the list"
 echo "a bit better:"
 echo " 'The nightmare before christmas'    should be:"
 echo " 'Nightmare before christmas ,The' "
 echo "             and  "
 echo " 'A man apart'  Would work best as:"
 echo " 'Man apart ,A' "
 sleep 20
 echo "just an idea...."
 echo "exiting program now"
 sleep 1
 echo "."
 # End Of File.

# 4  
Old 11-18-2005
heres a fast n quick version

Code:
# quick sort script was written on 11/17/2005 by chad cope
# you may share this file and use it on any system
# just keep this header intact.  -Chad Cope

echo "File name to be sorted?"
read file1
echo "New Filename?"
read file2
cat $file1 | sort > $file2
echo " "
echo "FINISHED!"

# End of script

# 5  
Old 11-18-2005
Not to put you down, but what you have done is write a script to make the sort command less efficient.
# 6  
Old 11-19-2005
maby so.
but it does what i need it to. so untill i insert some AWK code, it'l do
# 7  
Old 11-20-2005
Quote:
Originally Posted by Chadbot
maby so.
but it does what i need it to. so untill i insert some AWK code, it'l do
Just as suggestion, but even in a simple script you should try to maintain good code. With that in mind, you have not defined the shell to be used, and you have also included a UUOC.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Wget, grep, sort, sed in 1 command/script

Hi, I need to join these statements for efficiency, and without having to make a new directory for each batch. I'm annotating commands below. wget -q -r -l1 URL ^^ can't use -O - here and pipe | to grep because of -r grep -hrio "\b\+@\+\.\{2,4\}\+\b" * > first.txt ^^ Need to grep the output... (14 Replies)
Discussion started by: p1ne
14 Replies

2. Shell Programming and Scripting

Help to sort out... Possible use of sort command

I have an input like 4.3.6.66 4.3.6.67 4.3.6.70 4.3.6.25 4.3.6.15 4.3.6.54 4.3.6.44 4.3.6.34 4.3.6.24 4.3.6.14 4.3.6.53 4.3.6.43 4.3.6.49 4.3.6.33 4.3.6.52 4.3.6.19 4.3.6.58 4.3.6.42 (5 Replies)
Discussion started by: dnam9917
5 Replies

3. Shell Programming and Scripting

Is it Possible to sort a list of hexadecimal numbers using "sort" command?

Hello Everybody :) !!!. i have question in mind, is it possible to sort a list of hexadecimal numbers using "sort" command? (9 Replies)
Discussion started by: Kesavan
9 Replies

4. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

5. UNIX for Dummies Questions & Answers

sort command ... can I

Hi All, Simple question. I have a file (assumed unsorted) - can I sort said file but ignore the first two lines of the same said file (header lines) ?? Yes/No will suffice. If Yes - will keep searching. Cheers, Cam (7 Replies)
Discussion started by: Cameron
7 Replies

6. Shell Programming and Scripting

How to Sort Floating Numbers Using the Sort Command?

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)
Discussion started by: daniel.gbaena
7 Replies

7. 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

8. UNIX for Dummies Questions & Answers

the sort command

Explain the output of the command “sort -rfn file1 | more”. (0 Replies)
Discussion started by: wickbc
0 Replies

9. UNIX for Dummies Questions & Answers

sort command

i am wondering is it possible to sort a file by day of the week for example if the file is name oncall-date phone number john wednsday 00000000 jane tuesday 00000000 alice monday 00000000 kevin thursday 00000000 can it be sorted... (1 Reply)
Discussion started by: melkor
1 Replies
Login or Register to Ask a Question