Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

convert ksh commands to powershell

Posted on 2012-03-21
3
Medium Priority
?
476 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 71

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 71

Accepted Solution

by:
Qlemo earned 2000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Loops Section Overview
Screencast - Getting to Know the Pipeline

971 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