Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Fields from Text File 1

Status
Not open for further replies.

beaster

Technical User
Aug 20, 2001
225
US
I have a text file, beaster.txt which looks like:

MO STATE BLSTATE BLO BLA LMO BTS CONF
RXOTS-2-0-0 COM MBL 0010 0202 0F40 DIS UNCONF
RXOTS-2-0-1 COM MBL 0010 0202 0F40 DIS UNCONF
RXOTS-2-0-2 COM MBL 0010 0202 0F40 DIS UNCONF

It may have not lined up here, but it is lined up in my file. I need help removing the middle portion so I only end up with:

MO STATE BLSTATE BTS CONF
RXOTS-2-0-0 COM MBL DIS UNCONF
RXOTS-2-0-1 COM MBL DIS UNCONF
RXOTS-2-0-2 COM MBL DIS UNCONF

Then send to a new file beaster.txt > beaster1.txt

I dont want to have to use cut twice, so I was thinking awk or sed....

Thanks for the time!

Regards,
.//Beaster

 
beaster:

sounds like you just want fields 1, 2, 3, 7, 8:

awk '
{
printf("%s %s %s %s %s\n", $1, $2, $3, $7, $8)
} ' < org.file > beaster.txt


Regards,

Ed
 
Awesome Thanks, That worked perfect!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top