本文介绍了PowerShell是否有语言参考手册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在评估Windows PowerShell作为cmd.exe的替代品,用于命令行代码的基本过程自动化(例如大量Fortran作业的安装,执行和后处理)。我知道足够的perl和shell实现我想要的,但我想留在Windows工具链中,而不是需要培训我的同事Perl,Python,Ruby,Cygwin等。我在一家工程公司工作,所以我们不需要.NET或大量的框架用于Windows开发。简而言之:我们用内部代码压缩了很多数字,我需要一个合理的手段来自动执行重复的手动任务。



问题是我有麻烦评估语言,因为我找不到PowerShell的简洁可打印语言参考手册,



是的,我看过,但它是如此混乱和窒息与不相关的信息是不可用的。 Google倾向于将我指向该网站,并没有非常有帮助。



以下是我感兴趣的一些主题(unix和Perl类似物被注明):




  • 内在函数


    • 基本测试/分支/循环函数和流程控制


  • 变量的本质类型(布尔值,整数,浮点数,字符串)

  • 内部数据结构(标量,列表,关联数组,对象)

  • 运算符和运算符优先级

  • 特定于任务自动化语言的函数:


    • 进程控制(exec,fork,wait,kill)

    • 系统监视(ps,正常运行时间, ,netstat,df)

    • 文件和目录处理(查找,查找,哪个,cd,mkdir,touch,rm,rmdir)





我期待回答的其他问题:

$ PowerShell强类型(char,string,int,long,float,double)还是弱类型(variant)?
  • 常用的数据结构是可用的(标量,列表,关联数组),它们是一流的元素吗?

  • 是否有图书馆或模块系统?


    • 如果是,标准库中有什么?

    • 如果我有第三方库,我可以使用没有找到我需要的东西?


  • 这是一种程序化,功能性还是面向对象的语言 -

  • 什么是编码约定? (Perl最佳实践)

  • 是否有格式化期望 - 面向线性或自由格式?

  • 是空格还是案例显着?

  • 是否有字符集限制?


    • 语言是否8位清理?

    • 是否支持UTF-8,Unicode等。我很感兴趣的是在RTFM中找到M,但是请注意我正在评估阶段,所以从微软推出的$ 50左右的费用是非首发的。

      解决方案

      首先 - PowerShell命令行中提供非常有用的文档。只需键入:

        PS>帮助
      名称类别简介
      ---- -------- --------
      about_Alias HelpFile在Windows PowerShell中使用cmdlet和命令的备用名称
      about_aliases HelpFile描述如何在Windows
      中使用cmdlet和命令的备用名称about_Arithmetic_Operators HelpFile描述在Windows PowerShell中执行算术的运算符。
      about_Array HelpFile用于存储数据元素的紧凑数据结构
      about_arrays HelpFile描述用于存储数据元素的紧凑数据结构。
      about_Assignment_Operators HelpFile描述如何使用运算符将​​值分配给变量。
      ....

      它将回答您的大部分问题。



      请注意,您可以按照惯例调用exe文件(只需调用 netstat 即可)。因此,对于某些任务,您可以使用您所熟悉的工具。



      至于运营商优先级,我只看到Kirk Munro的一篇博文:



      图书(但仅适用于PowerShell V1)



      其他问题非常在Bruce Payette的一本书中有详细描述:。它覆盖了V1,但您可以从V2版本获取许多章节的MEAP。



      或者如果您只是评估,您可以看一些免费的书籍:




      • Jeffery Hicks:(查找Powershell TFM V1电子书)

      • Tobias Weltner:或



      对于一些最佳做法,您可以稍后再看Keith的书:


      I'm evaluating Windows PowerShell as a replacement for cmd.exe for basic process automation for command-line code (e.g. setup, execution, and post-processing of large numbers of Fortran jobs.) I know enough perl and shell to achieve what I want but I'm trying to stay within the Windows toolchain rather than needing to train my coworkers on Perl, Python, Ruby, Cygwin, etc. I work at an engineering firm so we have no need for .NET or extensive frameworks for Windows development. In short: We crunch a lot of numbers with in-house code and I need a reasonable means of automating the repetitive manual tasks.

      The problem is that I'm having trouble evaluating the language because I can't find a terse printable language reference manual for PowerShell,

      Yes, I've looked at Microsoft's site but it's so disorganized and choked with irrelevant information as to be unusable. Google tends to point me back to that site and hasn't been terribly helpful.

      Here are some of the topics I'm interested in (unix & Perl analogues noted):

      • Intrinsic functions
        • Basic test/branch/loop functions and flow control
      • Intrinsic types of variables (boolean, integer, floating-point, string)
      • Intrinsic data structures (scalar, list, associative array, object)
      • Operators and operator precedence
      • Functions specific to a task automation language:
        • Process control (exec, fork, wait, kill)
        • System monitoring (ps, uptime, lsof, fuser, netstat, df)
        • File and directory handling (find, locate, which, cd, mkdir, touch, rm, rmdir)
        • I/O (pipes, cat, tee, xargs, read, write, overwrite, append, seek)
        • Text-processing functions (awk, sed, grep, split, join, cut, fmt, strings)

      Other questions that I'd expect to be answered:

      • Is PowerShell strongly-typed (char, string, int, long, float, double) or weakly-typed (variant)?
      • Are common data structures available (scalar, list, associative array) and are they first-class elements?
      • Is there a library or module system?
        • If so, what is in the standard library?
        • Are there third-party libraries I can use if I don’t find what I need?
      • Is this a procedural, functional, or object-oriented language – or to what extent each?
      • What are the coding conventions? (Perl Best Practices)
      • Are there formatting expectations – line-oriented or free-form?
      • Is whitespace or case significant?
      • Is there a character set limitation?
        • Is the language ’8-bit clean’?
        • Does it support UTF-8, Unicode, etc.?

      I'm very interested in finding the M in RTFM, but note that I'm in the evaluation stage so dropping $50 or so on a tome from Microsoft Press is a non-starter.

      解决方案

      First of all - there is very very useful documentation available from PowerShell commandline. Just type:

      PS> help about
      Name                         Category  Synopsis
      ----                         --------  --------
      about_Alias                  HelpFile  Using alternate names for cmdlets and commands in Windows PowerShell
      about_aliases                HelpFile  Describes how to use alternate names for cmdlets and commands in Windows
      about_Arithmetic_Operators   HelpFile  Describes the operators that perform arithmetic in Windows PowerShell.
      about_Array                  HelpFile  A compact data structure for storing data elements
      about_arrays                 HelpFile  Describes a compact data structure for storing data elements.
      about_Assignment_Operators   HelpFile  Describes how to use operators to assign values to variables.
      ....
      

      It will answer most of your questions.

      Note that you can call exe files without any change as you are used to (just call netstat and you will see). So for some of the tasks you can use the tools you know and like.

      As for operators precedence I saw only one blog post by Kirk Munro: Essential PowerShell: Know your operator and enclosure precedence

      Books (but only for PowerShell V1)

      The others questions are very well described in a book by Bruce Payette: PowerShell in Action. It covers V1, but you can acces MEAP with many chapters from V2 version.

      Or if you just evaluate, you can have a look at some free books:

      For some best practises you may later look at Keith's book:Effective Windows PowerShell

      这篇关于PowerShell是否有语言参考手册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 08-22 21:32