Append filename to datafile


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Append filename to datafile
# 1  
Old 10-12-2006
Append filename to datafile

I am working on an shell script which checks for all the file starting with abc*.*
and if file found then the filelines need to append the file name in begining


can some one help with the filename appending...


for i in `ls $filename*.csv`
do
echo $i
--- NEED to append file name befor calling the loader
sqlldr
#mv $i $destdir/
done
exit 0
# 2  
Old 10-12-2006
Quote:
Originally Posted by Satyagiri
for i in `ls $filename*.csv`
do
echo $i
--- NEED to append file name befor calling the loader
sqlldr
#mv $i $destdir/
done
exit 0
something like
Code:
for i in `ls $filename*.csv`
do
echo $i
--- NEED to append file name befor calling the loader
sqlldr
#NOTE: almost pseudocode
mv $i tmpfile
echo "$i" > $i
cat tmpfile >> $i
rm tmpfile
#mv $i $destdir/
done
exit 0

# 3  
Old 10-12-2006
Hitori,
it does not replace the file name to all the lines in the file
# 4  
Old 10-12-2006
Quote:
Originally Posted by Satyagiri
Hitori,
it does not replace the file name to all the lines in the file
You want to append filename to each line in the file? Pipe the output of your program:

Code:
script | sed "s/^/$i: /" >> $i

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help on how to append on the filename when condition met.

Hi All, Seeking for your assistance on how to append the specific string when $3 condion met. ex. file1.txt ar0050046b16,5,888,0,0,0,0.00,0.00,0.00,0.00,25689.55 ar0050046b16,5,0,0,0,0,0.00,0.00,0.00,0.00,25689.55 ar0050046b16,5,0,0,0,0,0.00,0.00,0.00,0.00,25689.55 expected output:... (5 Replies)
Discussion started by: znesotomayor
5 Replies

2. Shell Programming and Scripting

Append string to filename

Hi, i wrote the script like... v_date=`date "+%Y%m%d"`; v_date1="rejects_"$v_date'.txt'; echo $v_date1; awk -F\| 'NF==4{ print $0>$v_date1;next} NF!=4 {print $0 >"murali.txt";next}' test1.txt while append data into file as coming like file is $v_date1,but i want data into file... (4 Replies)
Discussion started by: bmk
4 Replies

3. Shell Programming and Scripting

How to append filename to rows in gzip stdout

Assume I have 2 gz files with 2 lines each as below a.gz a1,a a2,a b.gz b1,b b2,b If I issue gzip -d -c *.gz I will get below in the stdout a1,a a2,a b1,b b2,b What I need it the filename appended to each row either at the front or back. a.gz,a1,a a.gz,a2,a (2 Replies)
Discussion started by: ericlim
2 Replies

4. Shell Programming and Scripting

sorting the datafile in an order given in second datafile

Hi, I have two files: first input file is having 7-8 columns, and second data file is like I want to arrange my datafile1 in the order given in second data file, by comparing the seconddatafile with the second column of first file and print the entire line....also if any... (2 Replies)
Discussion started by: CAch
2 Replies

5. Shell Programming and Scripting

append a filename with system date and time

Hi, There are similar kind of posts, but none seems like working for me. Please correct me if I'm wrong. I need append/rename file abc.txt with file processed date and time like abc_systemdatetimestamp.txt and move it to different folder. for example I have /source/data/abc.txt ... (1 Reply)
Discussion started by: amsn08
1 Replies

6. Shell Programming and Scripting

how to append current date to filename.tgz in perl

i would like to know how to append current date in a filename with .tgz extension. #!/usr/bin/perl my $date = `date + %Y%m%d`; system("sudo mv /tmp/nyucs01_config_backup.tgz /misc/nyucs01_config_backup_$date.tgz"); im getting this error message: sh: line 1: .tgz: command not found (7 Replies)
Discussion started by: linuxgeek
7 Replies

7. UNIX for Dummies Questions & Answers

Append Previous Days date to filename

I need to append previous days date to my file which is generated using a script. I am working on Solaris 10. Thanks! (2 Replies)
Discussion started by: Twisha
2 Replies

8. Shell Programming and Scripting

Combine a datafile with Master datafile, emergent!

Hi guys, my supervisor has asked me to solve the problem in 7 days, I've taken 3 days to think about it but couldn't figure out any idea. Please give me some thoughts with the following problem, I have index.database that has only index date: 1994 1995 1996 1997 1998 1999 I have... (6 Replies)
Discussion started by: onthetopo
6 Replies

9. UNIX for Dummies Questions & Answers

Append current date to filename

In C Shell programming I haven't successfully been able to append the date in the format mmddyyyy to a filename. I've tried the following: I can print out the date in the correct format: date +%x | sed ‘s/\///g I can create a variable with the filename: set newfile=changedfiles I can... (3 Replies)
Discussion started by: gigigi
3 Replies

10. UNIX for Dummies Questions & Answers

Append date to filename

What is the easiest way to append the date (year, month, day) to a filename? (5 Replies)
Discussion started by: hshapiro
5 Replies
Login or Register to Ask a Question