ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   Unix ksh script help (https://www.scoobynet.com/computer-and-technology-related-34/232447-unix-ksh-script-help.html)

marcmann 22 July 2003 03:29 PM

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

stevem2k 22 July 2003 04:02 PM

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

Steve

[Edited by stevem2k - 7/22/2003 4:06:15 PM]

marcmann 22 July 2003 04:12 PM

excellent mate - thats it.

Thanks

Marc :)

stevencotton 22 July 2003 07:58 PM

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



All times are GMT +1. The time now is 07:27 AM.


© 2024 MH Sub I, LLC dba Internet Brands