Appending multiple files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Appending multiple files
# 1  
Old 05-07-2015
Appending multiple files

I am trying to append multiple files in a directory

Code:
cat /a/file1.txt /a/file2.txt /a/file3.txt /a/file4.txt > /a/file.txt

Except file2 every other file is appending.

I interchanged file names and ran the command. Whatever file repeating in the second position is missing in output file. SmilieSmilie
Is there any other way to append other than cat, I mean either using awk or sed.

Last edited by eskay; 05-07-2015 at 08:41 PM..
# 2  
Old 05-07-2015
What operating system and shell are you using?

What output do you get from the command?:
Code:
type cat

What output do you get from the command?:
Code:
ls -l /a/file[1-4].txt /a/file.txt

# 3  
Old 05-08-2015
I use an ETL tool which is installed on Linux but we have a command stage which will let us use one line unix commands.

Code:
type cat 

output

cat is /bin/cat

ls -l /a/file[1-4].txt /a/file.txt

Output

/a/file[1-4].txt no such file or directory.

# 4  
Old 05-08-2015
This forum is for UNIX and Linux system commands. You are not using a shell; you're using "an ETL tool" which does not know how to do wildcard expansions, discards the 3rd word in every command line, and which I assume has other side effects that you have not described.

If you want advice about how to use UNIX and Linux system utilities, we'll be glad to help you. If you want advice about how to use a tool we have never seen, that you have not named, that we have no man page for, and that we have no way to search for it with Google; I have no idea how we can help you.
# 5  
Old 05-08-2015
We does use UNIX commands

If you can tell me other way to do the task I can try and let you know.

If you search my posts before I wrote here many times for support and everyone suggested a lot of unix commands which does helped me in using.

we just have a GUI version in ETL tool which let us use

Perl scripts, DOS batch files, and other command-line executable programs that you can call if they are not interactive.
# 6  
Old 05-08-2015
The cat command that doesn't work for you is a UNIX command that would work just fine if you were executing it directly with a non-interactive shell script on any UNIX or Linux system. So, what you have told us is incorrect. We can give you an awk script that will do what cat does; we can give you a sed script that will do what cat does; we can give you a shell script that will do what cat does. But if cat doesn't work, we have absolutely no reason to think that an awk, ed, ex, more, less, sed, or shell script is going to work either.

If what you said about being able to execute the command:
Code:
cat /a/file1.txt /a/file2.txt /a/file3.txt /a/file4.txt > /a/file.txt

and it works fine except that it doesn't process the 2nd file operand is true, put in a dummy 2nd file operand and try again:
Code:
cat /a/file1.txt /this/operand/will/be/ignored /a/file2.txt /a/file3.txt /a/file4.txt > /a/file.txt

or:
Code:
cat /a/file1.txt /a/file2.txt /a/file2.txt /a/file3.txt /a/file4.txt > /a/file.txt

# 7  
Old 05-08-2015
Thanks for your inputs

Dummy file didn't work either

---------- Post updated at 09:40 AM ---------- Previous update was at 01:07 AM ----------

Posted question in stack exchange and got this answer which worked. Thought to post here so if someone like me accidentally comes here can get an answer.

Code:
find . -type f | xargs cat | tee outputfile.txt

---------- Post updated at 01:33 PM ---------- Previous update was at 09:40 AM ----------

My sincere apologies,

Cat worked perfectly.

I had the first file with fixed length so it went out of actual window size and couldn't notice.

Sorry again.

Last edited by Scrutinizer; 05-08-2015 at 04:01 PM.. Reason: code tags
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending different columns of multiple files in awk

Hello All, I have three input files cat file1 col1|col2|col3 a|1|A b|2|B cat file2 col1|col2|col3 c|3|C cat file3 col1|col2|col3 d|4|D e|5|E i want below output file4 col1|col2 a|1 (6 Replies)
Discussion started by: looney
6 Replies

2. Shell Programming and Scripting

Appending multiple files through UNIX

Hi All, I have requirement where multiple csv files are present in a directory and each file contains a header.I need to append the contents of all the files into one file by removing header. Once the data is merged in one file ,I need to remove duplicates on nth column to find out distinct... (2 Replies)
Discussion started by: STCET22
2 Replies

3. UNIX for Beginners Questions & Answers

Appending time stamp for multiple file

Hi All, I am trying to append time stamp to all file with wild character. If you look above I want take all file with wild card *001* and append current time stamp to it. I did below code. But not sure if there is any easy way that can be done in a single step a=date +%s for... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

4. Shell Programming and Scripting

Copying multiple files and appending time stamp before file extension

Hi, I have multiple files that read: Asa.txt Bad.txt Gnu.txt And I want to rename them using awk to Asa_ddmmyytt.txt and so on ... If there is a single command or more efficient executable please share! Thanks! (4 Replies)
Discussion started by: Jesshelle David
4 Replies

5. Shell Programming and Scripting

Appending authorized_keys on multiple servers using ssh

Hi I have an ssh 'for' loop script to login and put a key on multiple servers. I need to append a file on each server but the command which works ok from the prompt does not work via the script. I have cat filename | ssh user@servername "cat >>append.file.name" I have tried to 'spawn' this in... (0 Replies)
Discussion started by: Grueben
0 Replies

6. Shell Programming and Scripting

Splitting record into multiple records by appending values from an input field (AWK)

Hello, For the input file, I am trying to split those records which have multiple values seperated by '|' in the last input field, into multiple records and each record corresponds to the common input fields + one of the value from the last field. I was trying with an example on this forum... (4 Replies)
Discussion started by: imtiaz99
4 Replies

7. UNIX for Dummies Questions & Answers

Help needed in Appending multiple lines

Hello, There is a log file A.log where new lines are getting added every minute. When ever any new lines are getting added in to A , the same lines needs to be appended to B.log I need to append these newly added lines to end of another file B through a shell script. I tried CAT but its... (2 Replies)
Discussion started by: twisterboy
2 Replies

8. Shell Programming and Scripting

reversing and appending data in multiple files

Hello, I have a some files that look like this: 0 3 1 5 2 8 3 7 I want to reverse and append the data so it looks like this: 3 7 2 8 1 5 0 3 0 3 1 5 2 8 3 7 I first thought about using cat and tac cleverly with some redirection and pipe in a one-liner but I couldn't get it to... (1 Reply)
Discussion started by: bigfoot
1 Replies

9. Shell Programming and Scripting

Appending same tring to multiple files in one line?

I have a string that I need to append to 3 files. Say, $ echo "Hello" I want to append this “Hello” to three files, file1, file2 and file3.The files are all in different directories and the file names have no common pattern.Can I do it in one line? If yes, how? :confused: (2 Replies)
Discussion started by: zombiezparadize
2 Replies

10. UNIX for Dummies Questions & Answers

Appending the two files

hi, I want to append to two files into a third file without new line like this: file 1: I am learning the unix file 2: Unix is very intersting When I am trying cat file1 file2 >> file3 I am getting: I am learning the unix Unix is very interesting But I want that to be in... (3 Replies)
Discussion started by: harish409
3 Replies
Login or Register to Ask a Question