简体   繁体   中英

How to split long Linux command up in Windows

I have a python program which I run in Linux with a lot of parameters. In Unix I use \\ to separate each line.

How can I format those same paths in Windows?

Here is the command I am using in Linux:

python -m bin.train \
  --config_paths="
      ./example_configs/nmt_small.yml,
      ./example_configs/train_seq2seq.yml,
      ./example_configs/text_metrics_bpe.yml" \
  --model_params "
      vocab_source: $VOCAB_SOURCE
      vocab_target: $VOCAB_TARGET" \
  --input_pipeline_train "
    class: ParallelTextInputPipeline
    params:
      source_files:
        - $TRAIN_SOURCES
      target_files:
        - $TRAIN_TARGETS" \

I want to do this in Windows. How can I do that in a single line (or) can I simply keep this as is and run it?

As referenced here , in Windows command line you can separate one long line into many lines with the '^' caret operator:

eg.

python -m bin.train ^
  --config_paths="
      ./example_configs/nmt_small.yml,
      ./example_configs/train_seq2seq.yml,
      ./example_configs/text_metrics_bpe.yml" ^
  --model_params "
      vocab_source: $VOCAB_SOURCE
      vocab_target: $VOCAB_TARGET" ^
  --input_pipeline_train "
    class: ParallelTextInputPipeline
    params:
      source_files:
        - $TRAIN_SOURCES
      target_files:
        - $TRAIN_TARGETS" ^

Open your notepad, write it all on a single line, save it with a .bat extension. You can save it anywhere and run it when you need to.

My naive attempt at making it all in one line is here:

python -m bin.train --config_paths="./example_configs/nmt_small.yml,./example_configs/train_seq2seq.yml,./example_configs/text_metrics_bpe.yml" --model_params "vocab_source: $VOCAB_SOURCE vocab_target: $VOCAB_TARGET" --input_pipeline_train "class: ParallelTextInputPipeline params: source_files: - $TRAIN_SOURCES target_files: - $TRAIN_TARGETS"

If that's somehow messed up you can probably fix it, I have no context to do any better

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM