I am using bashcat
to join several files into one, since there are more than a thousand folders, I do not want to make an instruction for each folder, how can I make a cycle so that it can go through all the folders and the files of the respective folders are joined.
What I do to join the files is the following code:
cat /media/user/PENDRIVE/test/0b8/2014322/2014322_0b8*.msd > /media/user/PENDRIVE/test/0b8/2014322/2014322_0b8.msd
cat /media/user/PENDRIVE/test/0b8/2014323/2014323_0b8*.msd > /media/user/PENDRIVE/test/0b8/2014323/2014323_0b8.msd
cat /media/user/PENDRIVE/test/0b8/2014324/2014324_0b8*.msd > /media/user/PENDRIVE/test/0b8/2014324/2014324_0b8.msd
How could I do it?
First of all, your question is too generic, you should try to make it more granular, for example you could ask how to list the folders that are in a particular location but not to a lesser or greater depth.
To answer your question, what you can do is list the folders inside the folder
/media/user/PENDRIVE/test/0b8
and process the output inside a loop, for example:What you see in the output is the full path to each of the folders you found. Then you can use the basename command to pass the folder name to a variable like so:
This should give you the folder name without the full path. So you can use the two variables you have to execute the command
cat
you mention in the question:you can debug the script in one line using the command
set -x
and disable debugging using the commandset +x
and you can also use it like this before running the final version:You should only remove the echo when you see that the commands that are executed in the while loop are correct