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

Pete pvdw at criticalcontrol.com
Wed Sep 15 14:36:24 UTC 2004


Quick and dirty

pwildenb at unpocoloco:~> more testfile.txt
"MAT 101     6 8"
"WBL -J      7 8"
"NCMC443     6 3"
pwildenb at unpocoloco:~> sed -e"s/\"//g" -e"s/ //g" testfile.txt > 
testfileOUT.txt
pwildenb at unpocoloco:~> more testfileOUT.txt
MAT10168
WBL-J78
NCMC44363

Pete


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. :)
>
> 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:
>
> 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. :)
>
> I've read 100 sed tutorials, and what seems like a simple thing I just 
> can't get to work.  If any kind souls would give me a hand offlist, 
> I'd be ever so greatful.
>
> Thanks in advance,
> -Shawn






More information about the K12OSN mailing list