Textutil - recursive concatenation


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Textutil - recursive concatenation
# 1  
Old 10-21-2013
Textutil - recursive concatenation

I'm trying to concatenate all .doc files within a directory and its subdirectories using the textutil . So basically I have the same question as in this thread, but it is already closed so that's why I'm creating a new one. In that ocasion, the suggested solution was using
Code:
find ./foo -maxdepth <number> -type f -name <filename_pattern> -exec cat \{} \;

In my case, I'm trying the following line:
Code:
]find . -maxdepth 3 -type f -name *.doc -exec cat \{} \;

However, I can't make it work. Any suggestions appreciated.

Moderator's Comments:
Mod Comment edit by bakunin: added the link you provided. If you need anything, just ask - we are here to help you.

Last edited by bakunin; 10-22-2013 at 04:48 AM..
# 2  
Old 10-21-2013
I would wrap the *.doc in double quotes and see if that helps.
Code:
find . -maxdepth 3 -type f -name "*.doc" -exec cat {} \;



Robin
Liverpool/Blackburn
UK

Last edited by rbatte1; 10-21-2013 at 08:27 AM..
# 3  
Old 10-21-2013
Thanks for the quick answer, Robin. Unfortunately, that still doesn't do what I need. The output is just one of the files. It is a file located in one of the subfolders, but it is as if it stopped searching after having found that .doc file, instead of continuing the search.
If it helps, I've found the following somewhere else (I can't post links yet), which can be used to recursively convert all doc files to txt:
Code:
find . -name *.doc -exec textutil -convert txt '{}' \;

Again, I need something similar, but I want to concatenate (-cat) all the files found.
# 4  
Old 10-21-2013
Only one thing springs to mind, that being if you have the re-direct to a file within the -exec and \; like this:-
Code:
find . -maxdepth 3 -type f -name "*.doc" -exec cat {} > outputfile \;

If you do, change it to this:-
Code:
find . -maxdepth 3 -type f -name "*.doc" -exec cat {} \; > outputfile

Does that help? I don't know why the find would stop at all, so I'm hoping that it's actually doing the work, but overwriting the output for each file.



Robin
# 5  
Old 10-21-2013
If those .doc files are MSWORD files, I don't this you can concatenate like so. They will have precursor info and also postfixes to the real text inside.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Concatenation script

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies

2. Shell Programming and Scripting

File concatenation

awk '{$2=$2":"$8"-"$3;$3=$NF;$4=$NF="";print $0 | $10=$10":"$8"-"$18;$11=$NF;$12=$NF="";print $0 }' design.txt Trying to concatenate specific fields in a spreadsheet and the others remain unchanged. I attached an excel spreadsheet (all the data comes from a design.txt), but I put an example... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

Help with String concatenation

I have a script which is migrated from AIX to Linux & now while running it is no able to concatenate string values The string concatenation step under while loop is not displaying desired result Please find below the piece of code: while read EXT_FILE ; do EXT_FILE=$EXT_FILE.ext.sent echo... (7 Replies)
Discussion started by: PreetArul
7 Replies

4. Shell Programming and Scripting

Line concatenation help

please help me on this.... cat /xx.txt 2:1 2 2:2 24 8:0 0 9:0 0 Expected result would be 2:1 2 2:2 24 8:0 0 9:0 0 (4 Replies)
Discussion started by: Aditya.Gurgaon
4 Replies

5. Shell Programming and Scripting

String Concatenation

Hi All, I need to concatenate the values in the array into a variable. Currently the code is : for (( i=1 ; i <= $minCount ; i++ )) do var="${var}""${sample_file}" done The output is : /tmp/1/tmp/2/tmp/3/tmp/4/tmp/5/tmp/6/tmp/7/tmp/8/tmp/9/tmp/10 I need a space between... (1 Reply)
Discussion started by: sh_kk
1 Replies

6. UNIX for Dummies Questions & Answers

Recursive Concatenation

Hi, I have a problem with concatenation text files. I have a directory, say 'foo' Inside this folder, I have many sub folders, say 'oof1, oof2 .... oof20' Each oof directory has a number of text files inside it. I need to concatenate all the text files in oof directories within foo...... (1 Reply)
Discussion started by: Kerensa@unsw.ed
1 Replies

7. Shell Programming and Scripting

Concatenation

How can I do this: date = 4 -----------> 04 Month= 3-----------> 03 I wish to make a varibale named Var1 which will hold the value of current date and month value as: 2 digits for date. 2 digits for month. So finally var1 should hold value as 0403 --- MMDD (11 Replies)
Discussion started by: Asteroid
11 Replies

8. UNIX for Dummies Questions & Answers

File Concatenation

Hi, I want to write a generic shell script, which can concatenate n number of files passed as parameter ;to an output file which is again a parameter Example catfl.sh outfl.txt a.txt b.txt c.txt (3 files to be concatenated into a file outfl.txt) catfl.sh outfl.txt a.txt b.txt(2 files to be... (3 Replies)
Discussion started by: samit_9999
3 Replies

9. UNIX for Dummies Questions & Answers

string concatenation

my input file contains thousands of lines like below 234A dept of education 9788 dept of commerce 8677 dept of engineering How do i add a delimeter ':' after FIRST 4 CHARACTERS in a line 234A:dept of education 9788:dept of commerce 8677:dept of engineering (7 Replies)
Discussion started by: systemsb
7 Replies

10. Shell Programming and Scripting

Concatenation

What is syntax for String concatenation? I have $1 as directory. $var is some variable value '/' String value. How do I have to concatenate if I have to run utility - util $1 followed by '/' followed by $var There is no space between these three. (2 Replies)
Discussion started by: videsh77
2 Replies
Login or Register to Ask a Question