This should be a simple script (and it would be nice if it worked)
Pardon me if I am taking the MVS JCL approach to building this script (I have only known 3 persons who COULD write JCL from scratch and only one who WOULD do so. The normal approach was to take someone else's script and modify it :-).
I have a bunch of files which were split with HJ Split or something similar. I have found and installed lxsplit which allows me to join them from the command line thusly: lxsplit -j mysplitfile.001 where the .001 file is the first in the set. Works great except I have a number of files to join and they have spaces in the names. So I pulled out a little script which vacuums or compacts Firefox database files as a starting example. Quote:
Quote:
Quote:
The first script pipes the command VACUUM to the sqlite program. In my case I am not executing any commands within lxsplit. I am simply running the program with a couple of arguments. I tried this Quote:
Quote:
I am obviously missing something simple. Can anyone please clue me in? TIA, Ken |
Hi,
Quote:
Quote:
I have never used lxsplit, but according to the project homepage this is how the syntax should be, in order to merge the split pieces into the original file: Code:
lxsplit -j smallfiles.bin.001 Code:
for i in *.001 ; do lxsplit -j "${i}" ; done Philip |
bad time for escaping :)]
Try: Code:
for i in *.001; do lxsplit -j "$i" ; done When you were testing, the part '...do echo "lxsplit -j" \"$i\" ' had proper escaping for embedding a " in the output... but you then removed the echo and the quotes around the lxsplilt -j.. but forgot to also remove the escape from the rest. I also missed the erroneous redirect... (sorry about that) |
you could get find to execute it
Code:
find . -type f -name "*.001" -exec lxsplit -j {} ';' |
Thanks Firerat, that did the trick. If I might impose on you for a little help in understanding...
The find command I understand. The exec part I think I understand and {} must be passing the name of the file to lxsplit. What I do not understand is how/why this loops through all of the found files in the directory. Does the -exec cause the command to be executed for each result of the find command? Thanks again, Ken |
basically, yes and yes
{} is the 'found' file/dir man find has more detail |
Thanks Firecat. I will have a look at the man page. I have used find to "find" files. Looks like it can do a lot more magic.
Ken |
just thought I would throw in a 'pure' bash solution
Code:
SAVEIFS=$IFS http://tldp.org/LDP/abs/html/internalvariables.html |
Quote:
Code:
for i in *.001; do lxsplit -j "$i" ; done |
My thanks to all who contributed. I have now joined my files back together and have learned some more scripting skills.
Regards, Ken |
All times are GMT -5. The time now is 01:32 PM. |