Concatenate input into svn list command with output, then pipe it to grep
I currently have the following shell command which only works partially:
svn list $myrepo/libs/ |
xargs -P 10 -L 1 -I {} echo $myrepo/libs/ {} trunk |
sed 's/ //g' |
xargs -P 20 -L 1 svn list --depth infinity |
grep .xlsx
where $myrepo
corresponds to the address of the svn server.
The libs folder contains several sub-folders (currently around 30, though eventually up to 100), each containing multiple tags, branches, and a trunk. I want to get a list of xlsx files contained only in the trunk folder of each of these subfolders. The command above works fine, but it only returns the relative path from $ myrepo / libs / subfolder / trunk /, so I return this:
1/2/3 / file.xlsx
Due to the potentially large number of files I would have to execute, I am executing it in two parallel steps using xargs -P (I do not and cannot use parallels). It also tries to do it in one command, so it can be used in php / perl / etc. and avoid multiple calls to sytem.
What I would like to do is combine the input to this part of the command:
xargs -P 20 -L 1 svn list --depth infinity
with an exit from it to give the following:
$myrepo/libs/subfolder/trunk/1/2/3/file.xlsx
Then pipe this to grep to find xlsx files.
I appreciate any help that can be provided.
source to share
If I can manage to explain your intent correctly, something like this might work for you.
svn list "$myrepo/libs/" |
xargs -P 20 -n 1 sh -c 'svn list -R "$0/trunk/$1" |
sed -n "s%.*\.xlsx$%$0/trunk/$1/&%p"' "$myrepo"
In short, we process the output from the internal svn list
to filter only files .xslx
, and include the full SVN path at the same time. So the processing takes place where the repo path is still known.
We're hacking things up a bit by passing "$myrepo"
as a "$0"
slave sh
, so we don't need export
this variable. The input from the outside svn list
comes as $1
.
(The repos I have access to have a slightly different format, so there might be a copy / paste error somewhere.)
source to share