The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Unable to use sort command in Shell Script racbern Shell Programming and Scripting 1 04-04-2008 02:25 AM
sort command naamas03 UNIX for Dummies Questions & Answers 2 11-11-2007 08:25 AM
Help in sort command srikanth_ksv UNIX for Dummies Questions & Answers 7 07-06-2005 08:45 PM
sort command milhan UNIX for Dummies Questions & Answers 1 10-08-2003 10:15 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 11-15-2005
Registered User
 

Join Date: Nov 2005
Posts: 4
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.
Reply With Quote
Forum Sponsor
  #2  
Old 11-15-2005
Registered User
 

Join Date: Aug 2004
Location: standing in a Sun 25k, Vienna
Posts: 78
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
Reply With Quote
  #3  
Old 11-15-2005
Registered User
 

Join Date: Nov 2005
Posts: 4
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.
Reply With Quote
  #4  
Old 11-18-2005
Registered User
 

Join Date: Nov 2005
Posts: 4
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
Reply With Quote
  #5  
Old 11-18-2005
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,590
Not to put you down, but what you have done is write a script to make the sort command less efficient.
Reply With Quote
  #6  
Old 11-18-2005
Registered User
 

Join Date: Nov 2005
Posts: 4
maby so.
but it does what i need it to. so untill i insert some AWK code, it'l do
Reply With Quote
  #7  
Old 11-20-2005
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,590
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0