bzr】 Bazaar is a version control system that helps you track project history over time and to collaborate easily with others【linux】


Install bazaar fastimport plugin

cd ~/.bazaar/plugins

bzr branch lp:bzr-fastimport fastimport

you can do it manually:

pip install

python setup.py build_ext -i

mv ... ~/.bazaar/plugins

probably you will need this patch:

https:launchpadlibrarian.net/174264005/fix-1314771.debdiff

How to migrate from Bazaar to git:

git init

bzr fast-export --plain . | git fast-import

copy】 Copy one or more files to another location.【win】


Syntax

      COPY [options] [/A|/B] source [/A|/B] [+ source2 [/A|/B]...] [destination [/A|/B]]

      COPY source1 + source2.. destination [options]

Key

   source Pathname for the file or files to be copied.

   /A ASCII text file (default)

   /B Binary file copy - will copy extended characters.

   /D Allow the destination file to be created decrypted.

   destination Pathname for the new file(s).

   /V Verify that the destination file, once written, can be read.

        No comparison with the source files occurs.

   /N If at all possible, create only short filenames (8.3) in the destination.

        This option can help when copying between disks that are formatted differently

        e.g NTFS and VFAT, or when archiving data to an ISO9660 CDROM.

   /L If source is a symbolic link copy the link to the target

        instead of the actual file the source link points to.

   /Y Suppress confirmation prompt, when overwriting files.

   /-Y Enable confirmation prompt, when overwriting files.

   /Z Copy files in restartable mode. If the copy is interrupted part way through,

        it will restart if possible. Also displays a '% complete' which counts up to 100%.

   /? Display help.

Combining files

    To combine files, specify a single file for the destination, but multiple files as the source. To specify more than one file use wildcards or list the files with a + in between each (file1+file2+file3).

    When copying multiple files in this way the first file must exist or else the copy will fail, a workaround for this is COPY null + file1 + file2 dest1

Binary copies

    "COPY /B ... " will copy files in binary mode.

    The /A and /B options can appear in multiple locations, with different meanings depending on location.

    Before any source - they will set the default mode for all source and destination files.

    After a source - they will set the mode for that source.

    After the destination - they will set the mode for the destination.

Copy from the console (accept user input)

    COPY CON filename.txt

    Then type the input text followed by ^Z (Control key & Z)

Prompt to overwrite destination file

    Under Windows 2000 and above, the default action is to prompt on overwrite unless the command is being executed from within a batch script.

    To force the overwriting of destination files use the COPYCMD environment variable:

    SET COPYCMD=/Y

Errorlevels

    If the file(s) were successfully copied %ERRORLEVEL% = 0

    If the file was not found or bad parameters given = 1

COPY will accept UNC pathnames.

COPY is an internal command.

Examples:

Copy a file in the current folder

COPY source_file.doc newfile.doc

Copy from a different folder/directory:

COPY "C:\my work\some file.doc" "D:\New docs\newfile.doc"

Specify the source only, with a wildcard will copy all the files into the current directory:

COPY "C:\my work*.doc"

Specify the source with a wildcard and the destination as a single file, this is generally only useful with plain text files.

COPY "C:\my work*.txt" "D:\New docs\combined.txt"

Create an empty (zero byte) file:

COPY NUL EmptyFile.txt

Quiet copy (no feedback on screen)

COPY source_file.doc newfile.doc >nul

Copy a file, but do not overwrite if the destination file already exists, this technique only works for a single file, no wildcards:

Echo n|COPY /-y c:\demo\source_file.txt c:\dir\dest.txt

call】 Call one batch program from another, or call a subroutine【win】


Syntax

      CALL [drive:][path]filename [parameters]

      CALL :label [parameters]

      CALL internal_cmd

Key:

   pathname The batch program to run.

   parameters Any command-line arguments.

   :label Jump to a label in the current batch script.

   internal_cmd Run an internal command, first expanding any variables in the argument.

The Microsoft help for the CALL command states: "Calls one batch program from another without stopping the parent batch program" to expand on this, it is true that the parent does not STOP, but it does PAUSE while the second script runs.

CALL a second batch file

    The CALL command will launch a new batch file context along with any specified parameters. When the end of the second batch file is reached (or if EXIT is used), control will return to just after the initial CALL statement.

    Arguments can be passed either as a simple string or using a variable:

    CALL MyScript.cmd "1234"

    CALL OtherScript.cmd %_MyVariable%

    Example

    ::----------start main.cmd-----------

    @Echo off

    CALL function.cmd 10 first

    Echo %_description% - %_number%

    CALL function.cmd 15 second

    Echo %_description% - %_number%

    ::----------end main.cmd-------------

    ::----------start function.cmd---------

    @Echo off

    :: Add 25 to %1

    SET /a _number=%1 + 25

    :: Store %2

    SET _description=[%2]

    ::----------end function.cmd-----------

    In many cases you will also want to use SETLOCAL and ENDLOCAL to keep variables in different batch files completely separate, this will avoid any potential problems if two scripts use the same variable name.

    If you execute a second batch file without using CALL you may run into some buggy behaviour: if both batch files contain a label with the same name and you have previously used CALL to jump to that label in the first script, you will find execution of the second script starts at the same label. Even if the second label does not exist this will still raise an error "cannot find the batch label". This bug can be avoided by always using CALL.

CALL a subroutine (:label)

    The CALL command will pass control to the statement after the label specified along with any specified parameters.

    To exit the subroutine specify GOTO:eof this will transfer control to the end of the current subroutine.

    A label is defined by a single colon followed by a name:

    :myShinyLabel

    If placed inside brackets, the label must be followed by at least one valid command, even just an ECHO or REM command.

    The maximum length for a label is 127 characters, no spaces.

    This is the basis of a batch file function.

    CALL :sub_display 123

    CALL :sub_display 456

    ECHO All Done

    GOTO :eof

    :sub_display

    ECHO The result is %1

    EXIT /B

    At the end of the subroutine an EXIT /B will return to the position where you used CALL

    (GOTO :eof can also be used for this)

Call and optionally continue

    In some cases you may want to call a second batch file (or subroutine) and continue only if it succeeded.

    CALL SecondScript.cmd || goto :eof

    This will goto:eof if SecondScript.cmd returns an errorlevel greater than zero, you can force an errorlevel by using Exit /b 1

Passing by Reference

    In addition to passing numeric or string values on the command line, it is also possible to pass a variable name and then use the variable to transfer data between scripts or subroutines. Passing by reference is a slightly more advanced technique but can be essential if the string contains characters that are CMD delimiters or quotes, otherwise passing a string like Start & middle:"and & End is likely to break something.

    @Echo off

    Echo:

    Set "var1=Red Pippin"

    Set "var2=St Edmunds Pippin"

    Set "var3=Egremont Russet"

    Echo: before: var1=%var1% var2=%var2% var3=%var3%

    call :myGetFunc var1 var2 var3

    Echo: after: var1=%var1% var2=%var2% var3=%var3%

    Echo:&pause&goto:eof

    ::----------------------------------------------

    ::-- Function section starts below

    ::----------------------------------------------

    :myGetFunc - passing a variable by reference

    Set "%~1=return64"

    Set "%~3=return65"

    EXIT /B

Buggy behaviour when using CALL

    Redirection via a pipe '|' does not always work as expected.

    This will work:

    CALL :function >file.txt

    This will fail:

    CALL :function | more

    More details can be found in this SO question: Why does delayed expansion fail when inside a piped block of code?

    If the CALL command contains a caret character within a quoted string "test^ing" , the carets will be doubled.

Advanced usage : CALLing internal commands

    CALL command [command_parameters]

    CALL can also be used to run any internal command (SET, ECHO etc) with the exception of FOR and IF.

    CALL will expand any variables passed on the same line. CALL REM only partly works: redirection operators, conditional execution operators and brackets will be not remarked.

    This is undocumented behaviour, in fact whenever CALL is run without a : prefix, it will always search disk for a batch file/executable called command before running the internal command. The effect of this extra disc access is that CALL SET is significantly slower than CALL, its use in loops or with a large number of variables should be avoided.

    Example

     @Echo off

     SETLOCAL

     set _server=frodo

     set _var=_server

     CALL SET _result=%%%_var%%%

     echo %_result%

    The line shown in bold has the '%' symbols tripled, CALL will expand this to: SET _result=frodo

    Each CALL does one substitution of the variables. (You can also do CALL CALL... for multiple substitutions)

    In many cases, DelayedExpansion is a better/faster method:

     @Echo Off

     Setlocal EnableDelayedExpansion

     Set _server=frodo

     Set _var=_server

     Set _result=!%_var%!

     Echo %_result%

Errorlevels

    If you run CALL SET this will reset ERRORLEVEL = 0 even though normally SET ... will fail to reset an ERRORLEVEL

    If you CALL a subroutine, the ERRORLEVEL will be left unchanged

    If you CALL a subroutine, with a label that does not exist ERRORLEVEL will be set to 1

    (call ) will set the ERRORLEVEL to 0.

    (call) will set the ERRORLEVEL to 1.

If you CALL an executable or resource kit utility make sure it's available on the machine where the batch will be running, test for it's existence with an IF command and throw an error if missing.

CALL is an internal command, (internally it is closely related to GOTO).

If Command Extensions are disabled, the CALL command will not accept batch labels.

sudo】 Execute a command as another user【linux】


List of an unreadable directory:

sudo ls /usr/local/scrt

To edit a file as user www:

sudo -u www vi /var/www/index.html

To shutdown the machine:

sudo shutdown -h +10 "Cya soon!"

To repeat the last command as sudo:

sudo !!

Save a file you edited in vim

:w !sudo tee > /dev/null %

Make sudo forget password instantly

sudo -K

List your sudo rights

sudo -l

Add a line to a file using sudo

echo "foo bar" | sudo tee -a /path/to/some/file

run root shell

sudo -i

to disable password for sudo for user superuser add

superuser ALL=(ALL) NOPASSWD:ALL

in /etc/sudoers

分类列表:


  1. 符号

腾图小抄 SCWY.net v0.03 小抄561条 自2022-01-02访问317464次