@cfajohnsn
Did you save it exactly as I posted it?
Ans: No
Did you cut and paste or retype it?
Ans: I cut, pasted and edited it as shown below.
If you changed anything, what did you change?
Ans: The only thing I changed is the value of logdir as shown below.
When you ran it, did you get any error messags?
Ans: No.
I saved the script as script.sh in $HOME/testing1 where I have several subdirectories and .txt files into them. I ran script.sh from the command prompt of $HOME/testing1 as ./script.sh
The only messages I got:
cat: file11.txt: input file is output file
cat: file22.txt: input file is output file
......
......
Here is the script I have used:
logdir=$HOME/testing1 ## adjust to taste
for dir in "$logdir"/*/
do
(
cd "$dir"
files=( *.txt )
cat "${files[@]}" > "${PWD##*/}.txt"
rm "${files[@]}"
)
done
Moderator's Comments:
|
|
As the original question was answered, and you were asked to start a new thread, I am closing this one.
|
|