Asked by:
cut -d ' ' -f7 test.tx

Question
-
Hi all,
can anyone please help the below linux command can be implement in powershell script
cut -d ' ' -f7 test.txt | cut -c 1-6
Please help asap
Tuesday, November 19, 2019 7:15 AM
All replies
-
Just type it at the prompt. All commands work in PowerShell.
Also use "SubS5tring"
You can learn how to work with srings in PowerShell here:
\_(ツ)_/
Tuesday, November 19, 2019 7:32 AM -
could you please help or elobrate how can we write linux cmd cut -d ' ' -f7 test.txt | cut -c 1-6
in powershell
Tuesday, November 19, 2019 8:14 AM -
What have you tried?
Please note that this is not a forum that excepts requests for code conversion. There is no Windows command that does what "cut" does and in Powe4rShell you will have to write a scripot. Start from the l9ink above and learn PowerShell or contqaqct a consultant to help you.
Observe the following:
Please carefully review the following links to set your expectation for posting in technical forums.
- This Forum is for Scripting Questions Rather than script requests
- How to ask questions in a technical forum
- How to post code in Technet Forums
Learning to script properly with PowerShell
- Microsoft Script Gallery
- Getting Started with Microsoft PowerShell
- PowerShell Documentation
- The PowerShell Best Practices and Style Guide
\_(ツ)_/
Tuesday, November 19, 2019 8:19 AM -
The first part would be something like:
get-content test.txt | foreach { (-split $_)[6] }
- Proposed as answer by LeeSeenLiMicrosoft contingent staff Friday, December 6, 2019 7:23 AM
Tuesday, November 19, 2019 1:39 PM -
How about this?
("a b c d e fgh IThinkThisIsWhatYouWant j").Split('',[System.StringSplitOptions]::RemoveEmptyEntries)[6].substring(0,6)
--- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)
- Proposed as answer by LeeSeenLiMicrosoft contingent staff Friday, December 6, 2019 7:23 AM
Tuesday, November 19, 2019 4:05 PM -
Hi,
Was your issue resolved?
If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
If no, please reply and tell us the current situation in order to provide further help.
Best Regards,
Lee
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.Friday, December 6, 2019 7:23 AM