Solved

shell script problem

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now