[K12OSN] Plea for Offlist sed/awk help...

Les Mikesell les at futuresource.com
Wed Sep 15 14:50:33 UTC 2004


On Wed, 2004-09-15 at 09:20, Shawn Powers wrote:
> I'm really sorry to ask for plain old help -- but I have to get some 
> data mangled, and sed/awk is kicking my butt. :)

That's why perl exists...

> I have one big data file that I need to modify before I can "awk" it 
> into different files/folders.  I'm more comfortable with awk than with 
> sed, so here's my problem:
> 
Perl can do all of the same things as sed and awk and then some with
fairly similar syntax.


> I need to take a chunk of data (that has been awked out of the big data 
> file) and remove all the spaces, then chop off the last 2 characters. 
> After that, I'm pretty sure I can use awk to create folders based on 
> certain fields, and copy specific data into files named by other fields. 
>   It's just that bit of "seding" that has got me...
> 
> Here's a sample of my chunk of the specific field of data:
> 
> "MAT 101     6 8"
> "WBL -J      7 8"
> "NCMC443     6 3"
> 
> That reminds me, I also need to strip those darn quotes out too. :)


sed -e 's/"//g' -e 's/ *//g' -e 's/..$//'

That's 'substitute " with nothing',
'substiture any number of spaces with nothing', and
'substitute the last 2 characters with nothing'

---
  Les Mikesell
   les at futuresource.com





More information about the K12OSN mailing list