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 Jul 22, 2003 | 03:29 PM
  #1  
marcmann's Avatar
marcmann
Thread Starter
Scooby Regular
 
Joined: Oct 2002
Posts: 163
Likes: 0
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
Reply
Old Jul 22, 2003 | 04:02 PM
  #2  
stevem2k's Avatar
stevem2k
Scooby Regular
 
Joined: Sep 2001
Posts: 4,670
Likes: 0
From: Kingston ( Surrey, not Jamaica )
Post

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

Steve

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

excellent mate - thats it.

Thanks

Marc
Reply
Old Jul 22, 2003 | 07:58 PM
  #4  
stevencotton's Avatar
stevencotton
Scooby Regular
 
Joined: Jan 2001
Posts: 2,710
Likes: 1
From: behind twin turbos
Post

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

Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
SD
Computer & Technology Related
6
Apr 24, 2002 03:35 PM
SD
Computer & Technology Related
5
Apr 24, 2002 10:29 AM
Karlos
Computer & Technology Related
9
Mar 10, 2002 03:23 PM
Blackscooby
Computer & Technology Related
3
Mar 1, 2002 09:25 AM




All times are GMT +1. The time now is 11:38 PM.