# multiple file processing

**URL:** <https://community.unix.com/t/multiple-file-processing/145719>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [April 30, 2003, 9:05pm UTC](https://community.unix.com/t/multiple-file-processing/145719 "2003-04-30T21:05:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagannatha](https://community.unix.com/letter_avatar/jagannatha/32/5_5575768a8748004e209b776fc1b2916d.png) [@jagannatha](https://community.unix.com/u/jagannatha)\
**Post date:** [April 30, 2003, 9:05pm UTC](https://community.unix.com/t/multiple-file-processing/145719/1 "2003-04-30T21:05:58Z")

</div>

I need to process a directory which will have a different amount of files in it from time to time. This is an error directory, I need to process each file indvidually in to one log file, then display the file to the user. So I would like to display the file name as well in the log file.  
example

------------------------------------------------------------------------  
File XXXXXX located in XXXXXXXXX  
file details, blah blah blah.

------------------------------------------------------------------------  
File XXXXXX located in XXXXXXXXX  
file details, blah blah blah.

------------------------------------------------------------------------

is this possible?

Thanks for all the help.

😕

---

<div class="post-metadata">

**Author:** ![oombera](https://community.unix.com/user_avatar/community.unix.com/oombera/32/69_2.png) [@oombera](https://community.unix.com/u/oombera)\
**Post date:** [May 1, 2003, 1:36am UTC](https://community.unix.com/t/multiple-file-processing/145719/2 "2003-05-01T01:36:45Z")

</div>

A few posts like [this one](http://www.unix.com/showthread.php?s=&threadid=7686) have addressed this before..

You can quickly concatenate all the files with this command if the xargs program is available:

```plaintext
cd /your/dir
(ls | xargs cat) > bigFile 2> /dev/null

```

Otherwise, you can use this (this will also allow you to add other text into bigFile), but it's pretty inefficient..

```plaintext
#! /usr/bin/ksh
cd /your/dir
for fn in `ls`
do
   echo "File $fn located in $PWD" >> bigFile
   cat bigFile $fn > TMP_00
   mv TMP_00 bigFile
done

```

---

<div class="post-metadata">

**Author:** ![TRUEST](https://community.unix.com/letter_avatar/truest/32/5_5575768a8748004e209b776fc1b2916d.png) [@TRUEST](https://community.unix.com/u/TRUEST)\
**Post date:** [May 2, 2003, 4:14pm UTC](https://community.unix.com/t/multiple-file-processing/145719/3 "2003-05-02T16:14:59Z")

</div>

the cat statement seems to make absolutely no sense.

you can't output two files at the same time with cat, can you??

---

<div class="post-metadata">

**Author:** ![oombera](https://community.unix.com/user_avatar/community.unix.com/oombera/32/69_2.png) [@oombera](https://community.unix.com/u/oombera)\
**Post date:** [May 2, 2003, 4:27pm UTC](https://community.unix.com/t/multiple-file-processing/145719/4 "2003-05-02T16:27:39Z")

</div>

Which block of code are you referring to?

In the first one, we list all the files and the xargs program tells the shell to concatenate everything into one big file. Any messages that would display (such as cat: input/output files 'bigFile' identical if bigFile is in the same directory as the files being concatenated) are sent to /dev/null so you don't see anything on screen..

In the second one, cat takes two files -- bigFile and $fn -- and concatenates them together into TMP\_00.. remember, that's the whole purpose of "cat"!

---

<div class="post-metadata">

**Author:** ![TRUEST](https://community.unix.com/letter_avatar/truest/32/5_5575768a8748004e209b776fc1b2916d.png) [@TRUEST](https://community.unix.com/u/TRUEST)\
**Post date:** [May 3, 2003, 9:22am UTC](https://community.unix.com/t/multiple-file-processing/145719/5 "2003-05-03T09:22:46Z")

</div>

guess I was wrong. i thought there was no way this code "cat bigFile $fn \> TMP\_00" would work
