read and drop files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers read and drop files
# 1  
Old 09-26-2008
read and drop files

I have hundreds of small files in csv format. I want to read them one at a time, insert the data into a table and then delete it.

data1 to data999.txt files needs to be read and data to be added to a table.

mysql -e"LOAD DATA INFILE 'data1.txt' INTO TABLE my_table;"
if echo $? = 0 then rm data1.txt
LOAD DATA INFILE 'data2.txt' INTO TABLE my_table;
if echo $? = 0 then rm data2.txt
LOAD DATA INFILE 'data999.txt' INTO TABLE my_table;
if echo $? = 0 then rm data999.txt

Is it possible?
# 2  
Old 09-26-2008
this won't work..
Code:
if echo $? = 0 then rm data2.txt

try it in this way..
Code:
if [ $? -eq 0 ];then
rm data2.txt
fi

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read files in shell script code and run a C program on those files

HI, I am trying to implement a simple shell script program that does not make use of ls or find commands as they are quite expensive on very large sets of files. So, I am trying to generate the file list myself. What I am trying to do is this: 1. Generate a file name using shell script, for... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

2. Shell Programming and Scripting

How to read log files from last read

Hi i am looking a way to look at a log file(log.txt) from the last time I've read it. However after some days the main log file(log.txt) is rename to (log.txt.1). So now i will have two log files as below. log.txt.1 log.txt Now, i have to read the log from the point where i have left... (3 Replies)
Discussion started by: sumitsks
3 Replies

3. UNIX for Dummies Questions & Answers

DNS Drop out

My boss use a MacBook and he encounter with DNS drop out and he cannot surf website for 1-2 mins. The DNS Service of my company is on UNIX server. I try to delete some unused IP of DNS Server in resolv.conf and dhcp.conf and I try to update root.hint file but The problem is not fixed. Please... (5 Replies)
Discussion started by: thsecmaniac
5 Replies

4. Web Development

Dynamic Drop Down Menu

I need to create a dynamic drop down menu which is populated by entries such as; htdocs/client1/index.php htdocs/client2/index.php htdocs/client3/index.php htdocs/client4/index.php etc. So htdocs/client*/index.php Is this possible? I know how to do this using normal arrays, but not... (2 Replies)
Discussion started by: JayC89
2 Replies

5. UNIX for Advanced & Expert Users

read() wont allow me to read files larger than 2 gig (on a 64bit)

Hi the following c-code utilizing the 'read()' man 2 read method cant read in files larger that 2gig. Hi I've found a strange problem on ubuntu64bit, that limits the data you are allowed to allocate on a 64bit platform using the c function 'read()' The following program wont allow to allocate... (14 Replies)
Discussion started by: monkeyking
14 Replies

6. Shell Programming and Scripting

Drop down menu

How to create a drop down menu in either bash or ksh? (3 Replies)
Discussion started by: proactiveaditya
3 Replies

7. Shell Programming and Scripting

Drop common lines at head/tail of a large set of files

Hi! I have a large set of pairs of text files (each pair in their own subdirectory) and each pair shares head/tail (a couple of first and last lines) but differs in the middle part. I need to delete the heads/tails and keep only the middle portions in which they differ. The lengths of heads/tails... (1 Reply)
Discussion started by: dobryden
1 Replies

8. Shell Programming and Scripting

using sed but want to drop last line

Howdy all. I have some scripts that read a text file looking for a keyword, then returning all the text until another keyword and puts it into a new file. Problem is, sed returns the entire last line that contains the 2nd keyword, and I don't want it! Here's an example of the sed script line: ... (21 Replies)
Discussion started by: atc98092
21 Replies

9. UNIX for Dummies Questions & Answers

Drop a Column from a File

Hi, I need to drop a column from a file. My .txt file having 20 columns first column as GroupBy column which is not necessery in further processing. So i need to create a new files without this column. Please help how to do this? Thanks, Raamc :rolleyes: (4 Replies)
Discussion started by: Raamc
4 Replies

10. UNIX for Dummies Questions & Answers

Drop Users

I know that this is a really simple and stupid question, but how do I drop / disconnect a user who is logged in? AIX 5.2 (2 Replies)
Discussion started by: trfrye
2 Replies
Login or Register to Ask a Question