Solved

shell script problem

Posted on 1998-06-16
2
269 Views
Last Modified: 2010-04-21
Hello,
Can someone give me a C shell script example to do following:
It can append all the files under given directory(this directory name is given as an augument) and sub-directories to a newly generated file recursively.

Thanks
0
Comment
Question by:tian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:tian
ID: 2008076
Edited text of question
0
 
LVL 2

Accepted Solution

by:
blowfish earned 100 total points
ID: 2008077
This should work.  It uses the find command to recurse through the directory and find
all "regular" files.  They are then concatenated using the cat command.  If the output
already exists, this script just keeps adding to the end, keep that in mind when you
run it.  

It requires two arguments, the first one is the path to the files to be read, the second is the path to the output file.  Don't write the output file into the same directory that you are reading input from.  

Hope this helps.  

#!/bin/csh

#  The first argument is the path to the files to be read
#  The second argument is the path to output file to be written

#  Since the find is recursive, the output should not go into the same
#  directory tree as the input

foreach X ( `find $1 -type f -print` )
  echo "Processing $X"
  cat $X >> $2
end

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question