Solved

convert ksh commands to powershell

Posted on 2012-03-21
3
446 Views
Last Modified: 2012-06-27
Hello,

How can I convert these commands ksh to powershell ?
typeset _CKID=`echo $0 | cut -d "." -f 2`
typeset _SID=`echo $0 | cut -d "." -f 1 | awk -F "_" '{print $NF}'`

Thanks

Regards

bibi
0
Comment
Question by:bibi92
3 Comments
 
LVL 70

Expert Comment

by:Chris Dent
ID: 37751385
Hey,

I'm not too familiar with awk, I can't figure out what that one is up to without test data.

cut is just splitting and can be replaced with -split. Awk may be doing something similar so you can always split again:
$typeset_CKID = ($args[0] -split '\.')[1]
$typeset_SID = ($args[0] -split '\.')[0] -split '_'

Open in new window

Chris
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 37754521
I assume the awk line is to just get the last part of something like
   one_two_three
generated from
   one_two_three.four.five

_CKID would then be "four", and _SID should be "three".

Chris is almost there then.
$_CKID = ($args[0] -split '\.')[1]
$_SID = (($args[0] -split '\.')[0] -split '_')[-1]

Open in new window

0
 

Author Closing Comment

by:bibi92
ID: 37766466
Thanks regards bibi
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now