append file name contents to a target file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers append file name contents to a target file
# 1  
Old 10-27-2006
append file name contents to a target file

Hi ,

I want to append the contents of many files (not knowing exactly how many files, i will get) in to one target file on a day today basis.
The file names are similar except last value (which is sequence number)

eg) file1_20061026_1
file1_20061026_2 etc.,

How can i read all the files one by one and append it to the target file.
I am very new to unix and it would be great if i get help from Unix Gurus.

Thanks in advance,
gops
# 2  
Old 10-27-2006
could be something like this:

Code:
root@mp-wst01 # echo "1" > file1_20_1
root@mp-wst01 # echo "2" > file1_20_2
root@mp-wst01 # for x in file1_20_* ; do cat $x >> target; done
root@mp-wst01 # more target
1
2
root@mp-wst01 #

regards pressy
# 3  
Old 10-27-2006
Thanks Pressy.

It worked.

Is it possible to assign the target file (in our example target) to some parameter file so that etl jobs can read the file name.

eg)
testparams (Parameter file name)
fromdate=
todate=
file_name=(here our target file name should appear)

Thanks in advance.
cheers,
gops
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies

2. Shell Programming and Scripting

Append file contents of one file into another

Hello there, I have a files f1.html, f2.html. I have a final file called final.html which is something like the below snippet <!DOCTYPE html> <html> <body> <h1 align="center">aaaaa Report</h1> <pppp><p><b>pppp Repository</b></p> </pppp> <qqqq><p><b>qqqq Repository </b></p>... (4 Replies)
Discussion started by: H squared
4 Replies

3. Shell Programming and Scripting

Folder contents getting appended as strings while redirecting file contents to a variable

Hi one of the output of the command is as below # sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/' Resource List : <br> *************************** 1. row ***************************<br> ... (2 Replies)
Discussion started by: vivek d r
2 Replies

4. Shell Programming and Scripting

Search and replace with mapping from a mapper file in a target file

Hello, I have a special problem. I have a file in 8 bit and would like to convert the whole database to 16Bit unicode. The mapping file has the following structure: The mapper is provided as a zip file The target file to be converted contains data in English and 8 bit Urdu mapping, a... (4 Replies)
Discussion started by: gimley
4 Replies

5. Shell Programming and Scripting

Replace partial contents of file with contents read from other file

Hi, I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file. i am able to... (2 Replies)
Discussion started by: seeki
2 Replies

6. Shell Programming and Scripting

I want to delete the contents of a file which are matching with contents of other file

Hi, I want to delete the contents of a file which are matching with contents of other file in shell scripting. Ex. file1 sheel,sumit,1,2,3,4,5,6,7,8 sumit,rana,2,3,4,5,6,7,8,9 grade,pass,2,3,4,5,6,232,1,1 name,sur,33,1,4,12,3,5,6,8 sheel,pass,2,3,4,5,6,232,1,1 File2... (3 Replies)
Discussion started by: ranasheel2000
3 Replies

7. UNIX for Dummies Questions & Answers

how to copy a file without remove the contents of the target file?

Hello every body, Kindly support me to "copy a file without remove the contents of the target file" Thanks in advance. :) Ahmed Amer Cairo,Egypt (2 Replies)
Discussion started by: ahmedamer12
2 Replies

8. UNIX for Dummies Questions & Answers

Script to append contents of one file to another

Hi, I want to write a script that will write a couple of lines into a file, including the output of another file... Can anyone help? Scenario Day 1 File 1 Contents --> Japan File 2 contents (to be wriiten by the script) --> Name: Sameer Country: Japan Day 1 File 1... (0 Replies)
Discussion started by: carlos_anubis
0 Replies

9. UNIX for Dummies Questions & Answers

compare 2 file contents , if same delete 2nd file contents

Give shell script....which takes two file names as input and compares the contents, is both are same delete second file's contents..... I try with "diff"...... but confusion how to use "diff" with if ---else Thanking you (5 Replies)
Discussion started by: krishnampkkm
5 Replies

10. Shell Programming and Scripting

how to append file contents at server1 to another file in server2

hi is there any way to append the file contents at server1 to another file in server2 by using scp. right now am transferring files to the server2 and using cat command for appending... (2 Replies)
Discussion started by: aemunathan
2 Replies
Login or Register to Ask a Question