Here I give Linux commands to allow the searching for filenames or strings within files without descending into the <.svn> subdirectories.
Archive for the ‘Shells’ Category
Suppose you have a set of changes on a Windows machine ready for commit. However, before committing, you’d like to check compilation on your Linux box. So, you create a patch file with a command such as
C:\my-dir> svn diff > patch.diff
Having copied the patch to your Linux box, you try the command
/home/me/my-dir$ patch -p0 < patch.diff
Unfortunately, you see many problems of the form
Hunk #1 FAILED at 234.
What is wrong?
The main stumbling block with splitting paths in Bash is converting a relative path into an absolute one.
Searching the Internet I found many partial solutions, but none was entirely satisfactory. There may be a better solution out there, but I didn’t find it.
To output a message to the error stream in a batch file, simply do this:
echo your message text 1>&2
Similar syntax may be used in Bash shell scripts:
echo "your message text" 1>&2
( fc /B "%file1%" "%file2%" | find "FC: no differences encountered" ) > nul && ( echo "%file1%" and "%file2%" are the same ) || ( echo "%file1%" and "%file2%" are different )
using conditional execution.
To test whether a directory (or “folder”) is empty, the code
if exist "%dir%\*.*" ( echo %dir% is non-empty ) else ( echo %dir% is empty )
does not work; it always reports “non-empty”.
( dir /b /a "%dir%" | findstr . ) > nul && ( echo %dir% non-empty ) || ( echo %dir% empty )
using conditional execution, however, does work.
It is often useful to be able to partially checkout a project or a subset of related projects from a repository. Having such a partial working copy may be helpful to allow the joint commit of related changes to more than one project. Thus helps to “tie” the changes in the projects’ histories.
Here are a couple of scripts to assist that process: one Bash shell script, and the equivalent DOS Batch file.