The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to combine 2 different files rdasari HP-UX 1 03-17-2008 05:19 PM
Need To Combine 2 Files goodmis Shell Programming and Scripting 4 02-21-2007 10:55 PM
combine two files fredao1 Shell Programming and Scripting 1 01-08-2007 09:29 PM
Combine 2 files Nekki UNIX for Dummies Questions & Answers 2 12-01-2005 02:46 AM
Move files using wildcards ??? Cameron UNIX for Dummies Questions & Answers 5 12-25-2001 02:22 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-03-2008
Enobarbus37 Enobarbus37 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 20
Using cat to combine files using wildcards

How do I use cat (presumably with a sh script) to combine all the files in a directory without listing them individually.

Thank you for your patience with this very elementary question.
  #2 (permalink)  
Old 04-03-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
try this:
Code:
for file in *; do cat $file >> newfile; done
  #3 (permalink)  
Old 04-03-2008
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
Or simply (if no subdir present):
Code:
cat dirname/* >newfile
  #4 (permalink)  
Old 04-03-2008
Enobarbus37 Enobarbus37 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 20
A complicating feature

Thank you for your replies!

Unfortunately, here is a partial list of my file names:

1 INSERM Avenir, Epidemiology of Sudden Death in the Population, Paris XI University.rtf

24% mortality in the ICD group, 55% in the pharmacological therapy group, and 48% in the group receiving no therapy.rtf

A frequently observed and notable aspect of SCD is its unpredictable and seemingly random nature of onset. Accordingly, one of.rtf

A multicenter experience with novel subcutaneous patch.rtf

A subcutaneous ICD system is a very useful new treatment approach. This technique is especially suitable for young children and.rtf


As you can see, they contain spaces, punctuation marks, and pretty much every other forbidden thing Unix can imagine.

What happens when I do "cat dirname/* > newfile" is that I just get the first file.

When I try the script: "for file in *; do cat $file >> newfile; done", it does not like the file names.

Sorry for the horrible complication...
Closed Thread

Bookmarks

Tags
cat

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0