Reputation: 5585
I'm using the following command to merge some files in multiple folders to one.
$dir=`ls`; for d in $dir; do files=`ls $d`; for f in $files; do cat $d/$f>>../results/$f; done; done
But after doing that, the original one is missing, how can I do that without deleting the old one.
Thanks.
Upvotes: 0
Views: 873
Reputation: 5903
Still unsure if I get your point correctly, but anyway, here`s the code:
$dir=`ls`
$res=$(ls ../results)
for d in $dir; do
files=`ls $d`
for f in $files; do
grep -q "$f" "$res" && f="${f}1"
cat $d/$f>>../results/$f
done
done
Upvotes: 1