Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

2010-01-08

Bash code: CVS status logging

This command has the effect of checking each of the indicated files in the source tree against the CVS repository - errors should be propagated to stderr if a file in the source tree does not exist in the CVS repository - this cmd should be refined into a script which tests for error on status and tries to add source files which do not appear to be in the repository....

for fn in *.{css,js,html,php} ./xml/*.xml ./xml/services/*.xml ./js/*.js ; 
    do echo $fn ; 
    cvs status $fn; 
    echo ""; done > cvs-status.txt

Note that the command cvs status [in src dir, w/ no args] does something similar to the above command, differing in that using cvs status may not handle the cases a source file exists which has not been added to the repository.

The CVS manpage does not address this:

       status [-lRqQ] [-v] [files...]
              Requires: working directory, repository.
              Changes: nothing.
              Display a brief report on  the  current  status  of  files  with
              respect to the source repository, including any ``sticky'' tags,
              dates, or -k options.  (``Sticky''  options  will  restrict  how
              `cvs  update' operates until you reset them; see the description
              of `cvs update -A...'.)

              You can also use this command to anticipate the potential impact
              of  a  `cvs update' on your working source directory.  If you do
              not specify any files explicitly,  reports  are  shown  for  all
              files  that  cvs  has placed in your working directory.  You can
              limit the scope of this search to the current  directory  itself
              (not  its  subdirectories)  with the standard -l option flag; or
              you can explicitly request recursive status reports with the  -R
              option.

              The  -v  option  causes the symbolic tags for the RCS file to be
              displayed as well.

2009-07-31

MySQL script execution

The following is text copied from the mysql(3) manual page:

You can execute SQL statements in a script file (batch file) like this:

   shell> mysql db_name < script.sql > output.tab

The MySQL version 5.x and greater also provide a mysqldump which has an XML output switch. This causes mysqldump to output XML on stdout such that the mysqldump output can be used directly in an XML document output stream.

2007-07-16

Bash du+sort Script

This is a one-liner that shows something about why grep has behaved so strangely in the past when we've tried to feed it regular expressions as the pattern to match:

  du -h | grep  "^[1-9]\+\.[0-9]\+[M]" | sort 

The trick here was to add the backslashes ('\') in front of the plus signs ('+'). apparenlty grep interprets the '+' literally if it is not escaped.

Note A: the Debian-blows-goats version of grep is not built with support for Perl regular expressions (bug #15051), which figures, since the Debian-POS developers only seem to know Python.

Note B: it apparenlty makes no difference to [this version] grep if the quote delimiters used in the above command are single- or double-quotes [this is counter-intuitive, since use of single quotes typically means no escape characters are needed], but the quotes must be there for the command to work - leaving them out causes the command to emit no output.