I am new to shell scripting. I am interested how to know how to sort a content of a file using shell scripting.
Here is an example:
fap0089-josh.baker
fap00233-adrian.edwards
fap00293-bob.boyle
fap00293-bob.jones
fap002-brian.lopez
fap00293-colby.morris
fap00293-cole.mitchell
psf0354-SKOWALSKI
psf0354-SLEE
psf0382-SLOWE
psf0391-SNOMURA
psf0354-SPATEL
psf0364-SRICHARDS
psf0354-SSEIBERT
psf0354-SSIRAH
bsi0004-STRAN
bsi0894-STURBIC
unit054-SUNDERWOOD
Considering the data above (this is a small set, I have more than 5.5 records), I would like to sort it like this:
- Number of entries starting with fap,psf,bsi,unit etc...
- The total number of environments for each type, i.e: each numeric after the word, 0004,0382,054 etc are environments. e.g: psf has 4 unique environments.
- The sum total
awksolution to your problem?awkis really its own programming language, but it's such an old part of Unix that many people consider usingawkas a shell solution.