Any views expressed within media held on this service are those of the contributors, should not be taken as approved or endorsed by the University, and do not necessarily reflect the views of the University in respect of any particular issue.

...in which I don't go up mountains

Tag: Git Bash

Radiohead: No surprises

Unix file counting challenge, Part 3: Counting with Shell Scripts

Reading Time: 7 minutes

This post follows on from Unix file counting challenge, Part 2, which in itself follows on from Part 1. No surprises there.

Post Summary

These are the steps I’ve been taking in developing a short Unix shell script to count a lot of files and directories by type.

Counts with text fragments

Can I turn a massive bureaucratic, er, challenge into a fun Unix challenge?

Reading Time: 12 minutes

Well.

I have been given an enormous number of files of different types, in many jumbled up directories and subdirectories on a network drive, to count. That ought to be a job for the Unix commands and shell scripting I’ve been learning at Software Carpentry over the last couple of weeks, right?

My initial thoughts were that this could be done with either the command line, probably involving ls, sort, regular expressions with uniq and counting options or a shell script looping through a file listing with some combination of those.

Time to fire up Git Bash, my trusty Unix terminal for Windows…

Powered by WordPress & Theme by Anders Norén

css.php

Report this page

To report inappropriate content on this page, please use the form below. Upon receiving your report, we will be in touch as per the Take Down Policy of the service.

Please note that personal data collected through this form is used and stored for the purposes of processing this report and communication with you.

If you are unable to report a concern about content via this form please contact the Service Owner.

Please enter an email address you wish to be contacted on. Please describe the unacceptable content in sufficient detail to allow us to locate it, and why you consider it to be unacceptable.
By submitting this report, you accept that it is accurate and that fraudulent or nuisance complaints may result in action by the University.

  Cancel