![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
Not to put you down, but what you have done is write a script to make the sort command less efficient.
|
|
#6
|
|||
|
|||
|
maby so.
but it does what i need it to. so untill i insert some AWK code, it'l do |
|
#7
|
||||
|
||||
|
Quote:
|
||||
| Google The UNIX and Linux Forums |