| Bill Marcum 2005-01-24, 8:55 pm |
| [Followup set to comp.unix.shell]
On Mon, 24 Jan 2005 12:20:31 GMT, Brent
<s@j.c> wrote:
> Hi all!
>
> I've got a little awk script that produces numerous files that need to be
> concatenated and they are named like this:
>
>
><filename1>.sort <filename1>.attach
><filename2>.sort <filename2>.attach
><filename3>.sort <filename3>.attach
>
>
> And so on... and I would need to append <filename1>.sort to
><filename1>.attach using some sort of generic script on files in the
> current directory.
>
> I've tried using a shell script loop (with cat) but can't think of a way
> to make sure that <filename1> goes with <filename1> and not another file.
> Maybe I could somehow remove the extensions in order to compare them?
>
The obvious awk solution would be to write the proper files to begin
with, but here is a shell script:
#!/bin/bash
for file in *.sort; do
echo "cat $file >> $(basename $file .sort).attach"
# if the output of the line above looks like what you want, then
# uncomment the line below
# cat "$file" >> $(basename "$file" .sort).attach
done
--
When you say that you agree to a thing in principle, you mean that
you have not the slightest intention of carrying it out in practice.
-- Otto Von Bismarck
|