Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Unix ksh script help

Thread Tools
 
Search this Thread
 
Old 22 July 2003, 03:29 PM
  #1  
marcmann
Scooby Regular
Thread Starter
 
marcmann's Avatar
 
Join Date: Oct 2002
Posts: 163
Likes: 0
Received 0 Likes on 0 Posts
Post

Hi,

I currently writing a ksh script but i'm stuck.

Example of what I'm trying to do.

find . -name "*.doc" -print

or

ls -ltr ¦grep .doc ¦awk '{print $9}'

either way this will list all documents in the current directory that have extensions ending in .doc.

What I want though is to find out how many instances of .docs there are from the generated list as above. So if the list brings back 5 .docs I want to be able to set a variable to state that 5 documents were found.

Any ideas how to do this?

Cheers

Marc
Old 22 July 2003, 04:02 PM
  #2  
stevem2k
Scooby Regular
 
stevem2k's Avatar
 
Join Date: Sep 2001
Location: Kingston ( Surrey, not Jamaica )
Posts: 4,670
Likes: 0
Received 0 Likes on 0 Posts
Post

grep -c , or wc -l the output of print $9

Steve

[Edited by stevem2k - 7/22/2003 4:06:15 PM]
Old 22 July 2003, 04:12 PM
  #3  
marcmann
Scooby Regular
Thread Starter
 
marcmann's Avatar
 
Join Date: Oct 2002
Posts: 163
Likes: 0
Received 0 Likes on 0 Posts
Post

excellent mate - thats it.

Thanks

Marc
Old 22 July 2003, 07:58 PM
  #4  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
Post

'ls -l *.doc | wc -l' should be all you need.

Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
SD
Computer & Technology Related
6
24 April 2002 03:35 PM
SD
Computer & Technology Related
5
24 April 2002 10:29 AM
Karlos
Computer & Technology Related
9
10 March 2002 03:23 PM
Blackscooby
Computer & Technology Related
3
01 March 2002 09:25 AM



Quick Reply: Unix ksh script help



All times are GMT +1. The time now is 09:55 AM.