Visit Our UNIX and Linux User Community

Find, copy, and append into one file

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find, copy, and append into one file
# 1  
Old 10-21-2009
Find, copy, and append into one file

Hi, I am trying to do something relatively easy, but am having some trouble getting it to work.

I have multiple files called "distances.log" in numerous subdirectories and sub-subdirectories within a directory. I would like the contents of each of these "distances.log" files to be appended to a single, new file called "distances_summary.log".

I know there are numerous ways to do this, but

Of the numerous things I tried, I tried:

find ./ -name "*distance.log" > distances_summary.log

and various modifications of it (trying not to print the path, but the contents of each). I think there's a much easier solution that I am not aware of. I know this is really silly - maybe I just need to take a break...

# 2  
Old 10-22-2009
find -iname "*distance.log" -exec cat {} >> distance_summary.log \;

  • find the files,
  • cat those files into required file.
# 3  
Old 10-22-2009
Great, thanks! I knew I should use "cat"...

Previous Thread | Next Thread
Test Your Knowledge in Computers #647
Difficulty: Medium
Window Maker is a free and open-source window manager for the X Window System designed to emulate NeXTSTEP's GUI.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find most recent file and copy to another directory.

Very new to shell scripting. Not sure if my title is correct but I will try and explain. Directory has 100+ files with this format, " ". When a new file gets created, the 16-19 characters in the file name gets incremented by 1. Ex...todays most recent file is... (14 Replies)
Discussion started by: askvip
14 Replies

2. Shell Programming and Scripting

Find and Copy file of specific location

Dear All, I need to transfer all files present in one location to another but those files should be of specific extension like. Find and copy all files of extension .xls, .pdf, .txt from location usr/tmp to location /per/Treat (6 Replies)
Discussion started by: yadavricky
6 Replies

3. Shell Programming and Scripting

Find string in a file and append character

Hi Experts, Is there a way to find a string in a file then append a character to that string then save the file or save to another file. Here is an example. >cat test.txt NULL NULL NULL 9,800.00 NULL 1,234,567.01 I want to find all NON NULL String and add a dollar sign to those... (9 Replies)
Discussion started by: brichigo
9 Replies

4. UNIX for Dummies Questions & Answers

Copy value and append value to a list

Hi, sorry if this has been asked before but I couldnt find it. Essentially I am trying to find a value next to an xml tag say abcd 12345678 the number 1-8 is the number i need to copy to a file of order numbers in my home directory ~/tn/ordernumbers.txt say for example there are 3 or... (3 Replies)
Discussion started by: rg01
3 Replies

5. UNIX for Dummies Questions & Answers

Copy and append

Ok, Here it goes. I have several file in a directory that I want to copy to another directory and append the date to the end of the file. I do not want to zip the I just need a copy. I would like the script to ask the user before copying each file in the directory to keep from making unneeded... (1 Reply)
Discussion started by: Dougj75
1 Replies

6. Shell Programming and Scripting

find and copy file to another directory..

Hi Everybody, i want a samll help to write a script. i had source location with :/user/bin (bin contains subdirectories with like names emails etc and had several files in each subdirectory) and target location with :/usr/scripts (having same subdirectories names and had some files)... (1 Reply)
Discussion started by: Reddy482
1 Replies

7. Solaris

Find a file and xarg mv to append date to file

Hello All, What I would like to do is search for a file and then run a mv command to rename the file to have todays date appended to it. The find when I run it finds eight or so files and I would like to append a date stamp to each file. If possible using one line command would be great. Can... (6 Replies)
Discussion started by: jacktravine
6 Replies

8. Shell Programming and Scripting

find, if exists then append for file with same name

I will have to process multiple files with same name everyday. My requirement is: If on a certain day I see that filename.txt exists then the contents of the filename.txt would be added/append to the former file contents.Each time it sees the file the content would be added.But the header ... (8 Replies)
Discussion started by: RubinPat
8 Replies

9. UNIX for Dummies Questions & Answers

need to help to find and copy to a file

I am trying to search for files and copy them into a text file. Can anybody help me how to do that. find /test/sds/data -name "*.*" -mtime -365 -exec ls -altr {} \ this is my find command and want to copy the result to a file. (2 Replies)
Discussion started by: pujars1
2 Replies

10. UNIX for Advanced & Expert Users

find and copy string in a file

Hello there I need to find a string in an file, and then copy to a new file from the previous 6 lines to 41 lines after the string. So, what i need to do , and just don't know how, is to find the string and copy 48 lines where the string would be in the 7th line. I don't know if i can do it with... (10 Replies)
Discussion started by: vascobrito
10 Replies

Featured Tech Videos