The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Key Scripter 1.4 (Default branch) iBot Software Releases - RSS News 0 05-06-2008 05:50 PM
Key Scripter 1.1 beta (Default branch) iBot Software Releases - RSS News 0 03-11-2008 06:50 AM
Key Scripter 0.9 (Default branch) iBot Software Releases - RSS News 0 02-12-2008 01:30 PM
new scripter Gwoodhouse0 Shell Programming and Scripting 1 09-26-2007 09:12 AM
Use of #! at the begining ? jambesh Shell Programming and Scripting 1 07-24-2007 03:08 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-09-2007
C.Ronaldo-7- C.Ronaldo-7- is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 1
Begining Shell scripter

I am trying to write for my class project a shell script, using bourne shell, that will take one command, either -l or -w. If -l is entered then the script should output the names of all the files in my working directory sorted in increasing order of the number of lines in the file. If -w is input then the same ill be done except that it will be sorted in increasing order by the number of words in the files. I know the solu'n will use the command ls and a pipeline to sort. but I don't know how to list the files or sort the files by the number of words or lines that they have. so far I have
#!/bin/sh

print=`ls | sort`
echo $print

this is not exactly correct but if I knew how to sort the files according to the number of lines each had, then I could rearrange this code to adapt.
Any help would be really appreciated. The project is not worth much at all but I am curious as how to sort this way. Thank you.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0