Sponsored Content
Full Discussion: Need help
Top Forums Shell Programming and Scripting Need help Post 302104644 by dsravan on Friday 26th of January 2007 11:18:04 AM
Old 01-26-2007
Need help

I have a problem. I have a direcotry where i have files named as below

-rwxr-x--- 1 sadalbid dwro 953 Jan 4 17:03 tables.telg.subs.txt
-rwxr-x--- 1 sadalbid dwro 79 Jan 4 17:03 tables.telg.sub2.txt
-rw-r--r-- 1 sadalbid dwro 268 Jan 4 17:03 tables.telg.prty.txt
-rwxr-x--- 1 sadalbid dwro 349 Jan 4 17:03 tables.telg.prod.txt
-rwxr-x--- 1 sadalbid dwro 45 Jan 4 17:03 tables.telg.addr.txt

I have to loop thruogh these text files and get the table name which is the first field in the file. for e.g cat on one of the files above will produce o/p like this

cat tables.telg.subs.txt

acct STD
acct_chrg_off_actvt STD
acct_crdt_hist STD
acct_sgmnt_hist HST
acct_sts_hist HST
acct_upd STD
acct_upd2 STD
acct_inv_due_dt STD
cllctn_agnc_avt AVT
cpni_srv_hist HST
cpni_sts_avt AVT
cpni_sts_hist HST

I have to take the first column from each file here which is the table name and replace in another file which deletes the data from all these tables. How can i loop through all the files and replace the table name in my actual script to delete the data from the tables in these files only. Please suggest.

My delete script looks like this; I want to make it automated so that i don't need to run it manually.

delete from acct;
.IF ERRORCODE <> 0 Then .QUIT 1
delete from acct_chrg_off_actvt ;
.IF ERRORCODE <> 0 Then .QUIT 2
 
YYFIX(1)						    BSD General Commands Manual 						  YYFIX(1)

NAME
yyfix -- extract tables from y.tab.c SYNOPSIS
yyfix file [tables] DESCRIPTION
Programs have historically used a script (often named ``:yyfix'') to extract tables from the yacc(1) generated file y.tab.c. As the names of the tables generated by the current version of yacc(1) are different from those of historical versions of yacc(1), the shell script yyfix is provided to simplify the transition. The first (and required) argument to yyfix is the name of the file where the extracted tables should be stored. If further command line arguments are specified, they are taken as the list of tables to be extracted. Otherwise, yyfix attempts to deter- mine if the y.tab.c file is from an old or new yacc(1), and extracts the appropriate tables. The tables ``yyexca'', ``yyact'', ``yypact'', ``yypgo'', ``yyr1'', ``yyr2'', ``yychk'', and ``yydef'' are extracted from historical versions of yacc(1). The tables ``yylhs'', ``yylen'', ``yydefred'', ``yydgoto'', ``yysindex'', ``yyrindex'', ``yygindex'', ``yytable'', ``yyname'', ``yyrule'', and ``yycheck'', are extracted from the current version of yacc(1). FILES
y.tab.c File from which tables are extracted. SEE ALSO
yacc(1) HISTORY
The yyfix command first appeared in 4.4BSD. BSD
March 23, 1993 BSD
All times are GMT -4. The time now is 04:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy