Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

cut command in powershell windows

function cut {
  param(
    [Parameter(ValueFromPipeline=$True)] [string]$inputobject,
    [string]$delimiter='s+',
    [string[]]$field
  )

  process {
    if ($field -eq $null) { $inputobject -split $delimiter } else {
      ($inputobject -split $delimiter)[$field] }
  }
}


PS C:> 'hi:there' | cut -f 0 -d :
hi

PS C:> 'hi:there' | cut -f 1 -d :
there

PS C:> 'hi:there' | cut -f 0,1 -d :
hi
there

PS C:> 'hi:::there' | cut -f 0 -d :+
hi

PS C:> 'hi   there' | cut
hi
there
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #cut #command #powershell #windows
ADD COMMENT
Topic
Name
9+7 =