|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Equivalent UNIX 'cut' command in Windows Powershell If you are using the UNIX like system, you might have seen that, there we use cut command to extract few fields from a file. For example Code: cut -d";" -f 4-5 file.txt |
#2
| |||
| |||
Re: Equivalent UNIX 'cut' command in Windows Powershell I tried the following command but it is little more tricky and lengthy. Code: Get-Content Test.txt | %{"$($_.Split(',')[2..4])"} | Foreach-Object {$_ -replace " ", ","} |
#3
| |||
| |||
Re: Equivalent UNIX 'cut' command in Windows Powershell How about the following commands for Windows Shell Code: PS> get-content test.csv name,value1,value2 foo,1,2 foo,1,2 foo,1,2 foo,1,2 Code: PS> import-csv test.csv | select value1 value1 ------ 1 1 1 1 Code: PS> import-csv test.csv | foreach-object {[int]$_.value1 + 1} 2 2 2 2 |
![]() |
|
Tags: command, cut, split, unix, windows powershell |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Access from command line using the PowerShell | Ander K | Software Development | 4 | 29-12-2010 06:41 AM |
Linux and UNIX shutdown command help | Morea | Operating Systems | 4 | 27-03-2010 09:32 PM |
Powershell 'Get-Mailbox' command | Bracken | Software Development | 3 | 03-06-2009 07:04 PM |
The Linux equivalent of Sun command 'prtdiag' | dan-dan | Operating Systems | 3 | 27-05-2009 02:03 PM |
Unix command rm -rf | RIMON | Software Development | 1 | 18-03-2009 09:46 AM |