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
print=`ls | sort`
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.
new to scripting (and unix!) here. Im trying to write a script for something i have to do for work and for some reason it just isnt working.
im using the ksh.
Can someone please tell me why
print Using $CONFIG
prints... (1 Reply)
i have some doubt on #!/bin/bash or #!/bin/ksh at the begining of script.
Need to know folowing thing ?
-- what would be the problem if i will mention in the first line #!/bin/bash
and will use korn shell syntax and the reverse ?
-- Can i mention at the... (1 Reply)