Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

shell script problem

Posted on 1998-06-16
2
Medium Priority
?
281 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 400 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

Technology Partners: 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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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

596 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