Solved

shell script problem

Posted on 1998-06-16
2
256 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
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

772 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