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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parse file and delete field

Status
Not open for further replies.

schocku

Programmer
Nov 20, 2001
23
US
Hi everybody,

I have a file (a.dat) with the following data in it :

10/17/2003^F^555555^F^333^F^HELLO^F^04-15-2003^R^
10/17/2003^F^444444^F^11^F^^F^09-15-2003^R^
10/17/2003^F^555555^F^333^F^WATER^F^04-15-2003^R^
10/17/2003^F^^F^333^F^FIRE^F^04-15-2003^R^
10/17/2003^F^111^F^333^F^WIND^F^04-15-2003^R^
....

Based on the field number given by the user I need to delete the field from all lines in the file and output it to another file. For example if the user input is "a.dat 3" (which means user wants 3rd field to be deleted from file a.dat) then my output should be

10/17/2003^F^555555^FHELLO^F^04-15-2003^R^
10/17/2003^F^444444^F^^F^09-15-2003^R^
10/17/2003^F^555555^F^WATER^F^04-15-2003^R^
10/17/2003^F^^F^FIRE^F^04-15-2003^R^
10/17/2003^F^111^F^WIND^F^04-15-2003^R^
....

Could you please help me with a script to do this. Thanks.
 
I got an answer to this from the AWK forum.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top