Need help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help
# 8  
Old 01-26-2007
how to make tab delimited file

i can edit the files and make them space or tab delimited. I don't know how to make them tab delimited so that we can use the Glenn
script. Kindly suggest
# 9  
Old 01-26-2007
Give this a try:
Code:
integer i=0
tr '\t' ' ' < tables.* | cut -d" " -f1 | while read table; do
  i=i+1
  echo "delete from $table;"
  echo ".IF ERRORCODE <> 0 Then .QUIT $i"
done > outfile


Last edited by Glenn Arndt; 01-26-2007 at 01:03 PM.. Reason: Syntax!
# 10  
Old 01-26-2007
I tried using the script on one file and here is the o/p

Quote:
tr '\t' ' ' tables.telg.subs.txt | cut -d" " -f1
Usage: tr [ -cds ] [ String1 [ String2 ] ]
# 11  
Old 01-26-2007
I think if we can use sed to get the data till the first space should be fine. But how can we incorporate that in the code. I have one more question as my files always don't start with tables*. They may also look like

sun_market.txt
cast_tables.txt
tables_other.txt
tables_2.txt
tables.txt
tables.telg.othr.txt

In this case can i have all the file names in one single file and use our script.

Kindly suggest.

Last edited by dsravan; 01-26-2007 at 01:16 PM..
# 12  
Old 01-26-2007
Quote:
Originally Posted by dsravan
I tried using the script on one file and here is the o/p
I edited my previous post to fix the syntax of the tr command. Note the use of "< tables.*" rather than just "tables.*"
# 13  
Old 01-26-2007
Amazing !!!! It's working. Can you please answer my other question.

If i have files not starting with the same name "tables" I need to loop through those tables also. So should i have to copy all the file names to a seperate file and use our script. Will that work.
# 14  
Old 01-26-2007
O otherwise if i can pass the name of the file as parameter that would work too. But what change do i need to make in the script for that.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question