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!

Quick Help on Cutting up to : 1

Status
Not open for further replies.

beaster

Technical User
Aug 20, 2001
225
US
I have a file which has text similiar to below:

pre_build_j1:RXMOI:MO=RXOTG-
pre_build_j1:RXESI:MO=RXOTG-62;
pre_build_j1:RXBLE:MO=RXOTG-62;
pre_build_j1:RXMOI:MO=RXOCF-62,TEI=62;
pre_build_j1:RXMOC:MO=RXOCF-62,SIG=CONC;
pre_build_j1:RXMOI:MO=RXOIS-62;
pre_build_j1:RXMOI:MO=RXOTF-62,TFMODE=SA;
pre_build_j1:RXMOI:MO=RXOCON-62,DCP=64&&87;
pre_build_j1:DTBLE:DIP=150RBLT;

I just want to remove everything on each line up to the : colon and output to one file called pre_build_final

I dont know how many lines in each file, but only want what is after : colon.

Thanks,
Beaster


 

{gsub(/^[^:]*:/,"");print}

deletes everything up to and including the first colon. CaKiwi
 
So just put it in a file called nawk.test and run it as:

nawk -f nawk.test input.file

??
 
yes, or enter

nawk '{gsub(/^[^:]*:/,"");print}' input.file > output-file CaKiwi
 
I konw we're supposed to be talking awk but,
cheapest would be:

cut -d&quot;:&quot; -f2- < input-file > pre_build_final
Cheers,
ND [smile]

bigoldbulldog@hotmail.com
 
Yes - bigoldbulldog, you are a programmer after my style. Cut is much more economical, however there isn't a forum for cut *sigh*.

But always remember that the RIGHT solution is the one that works and that you understand why it works. After all, when the input changes, who will be the person fixing the script? Einstein47
(&quot;If vegetarians eat vegetables, what do humanitarians eat?&quot;)
 
All the posts work wonderfully! Thanks for the assistance!

I think Einstein47 put it best:

But always remember that the RIGHT solution is the one that works and that you understand why it works. After all, when the input changes, who will be the person fixing the script?

ME.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top