Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hi i try to transcript an awk command to powershell
i have a text file
SQLBefore:=
UPDATE SYSADM.PS_S1_R_FLWUP
SET S1_FLWUP_DATE_CHK=SYSTIMESTAMP
, S1_FLWUP_DATE_LAST=NULL
WHERE S1_FLWUP_NAME='GGGGG_ETAT_JJ'
SQLAfter:=
UPDATE SYSADM.PS_S1_R_FLWUP
SET S1_FLWUP_DATE_LAST=SYSTIMESTAMP
, S1_FLWUP_STAT_SID=1
WHERE S1_FLWUP_NAME='TTTTT_ETAT_'
SQLFailed:=
UPDATE SYSADM.PS_S1_R_FLWUP
SET S1_FLWUP_DATE_LAST=S1_FLWUP_DATE_FRST
, S1_FLWUP_STAT_SID=3
WHERE S1_FLWUP_NAME='JJJJ_ETAT_JJJ'
And i would like to do the same than this unix command in powershell
cat $this_file|awk '/SQLAfter/,/SQLFailed/ {print $0}'| grep -v SQL|sed -e 's/^$//'
It's return
UPDATE SYSADM.PS_S1_R_FLWUP
SET S1_FLWUP_DATE_CHK=SYSTIMESTAMP
, S1_FLWUP_DATE_LAST=NULL
WHERE S1_FLWUP_NAME='GGGGG_ETAT_JJ'
I'm getting stuck to do the delimiter like awk, between "SQLBefore:=" and "SQLAfter:=" with powershell
Thanks for your help.
I'm a beginner of powershell sorry for my english
One possibility, assuming I'm reading the question correctly (however "bad" you think your English might be I assure you it's considerably better than my AWK).
((get-content testfile.txt -raw) -split 'SQL(?:Before|After):=')[1]
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am extracting oracle version from windows using powershell command and i get result as 10.2.0.3.0Patch2, however i need to extract only numeric value i.e. 10.2.0.3.0 (only version number). Any way we can do it ?
Version info extracted is =
10.2.0.3.0 Production, 10.2.0.3.0Patch2 Production, 10.2.0.5.0 Production, 11.2.0.4.0 Production
You can use a regular expression to extract a substring. Example:
"10.2.0.3.0Patch2" | Select-String '((?:\d{1,3}\.){4}\d{1,3})' | ForEach-Object {
$_.Matches[0].Groups[1].Value
}
# Outputs the string '10.2.0.3.0'
You can read more about regular expressions by reading the about_Regular_Expressions help topic:
PS C:\> help about_Regular_Expressions
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have a file as shown below.
2.6G kishan /home/Srikishan
10G kishan /home/data/aa
150G kishan /home/Junk
300G kishan /home/junk2
I want a command which displays only the folders which are consuming more than 50G memory. Can someone help me how I can code it using shell or Perl or TCL.
As a Perl one-liner
perl -ne'/([\d.]+)G/ and $1 > 50 and print' myfile
output
150G kishan /home/Junk
300G kishan /home/junk2
This will also ignore lines that don't contain a field like 999G
And here's the Tcl contender. It looks at every line in the file whose name is in the filename variable and prints those lines that begin with a floating-point number larger than 50.
package require fileutil
fileutil::foreachLine line $filename {if {[scan $line %f] > 50} {puts $line}}
Using awk you can do:
awk -F 'G' '$1>50' file
150G kishan /home/Junk
300G kishan /home/junk2
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i have a problem, I am new in Perl, so.
I want to get output from command i send to check if its done, for example:
In my module i run command my_zip_command file a_lot_of_file' and i want to my module wait until the massage 'all file were zip correctly' will be printed.
I tried get the STDOUT but it didnt work for me, or i just doing it wrong.
bash>my_zip_command file a_lot_of_file
>ziping file1 100%
>ziping file2 100%
>ziping file3 100%
>all file were zip correctly
bash>
Thanks for all your help
If you are trying to
Run a command from your perl script and
Capture the output of that command inside your perl script
this is the simplest way I can think of.
my #output = `my_zip_command file a_lot_of_file`;
#output will hold the complete output of the command.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I have file as below.
ID || DATE || AMOUNT
XX||20130801##20130901##20131001##20131101||100##200##300##400
and I want the output as below using perl.
xx||20130801||100
xx||20130901||200
xx||20131001||300
xx||20131101||400
Please help me how to convert using perl.
perl -F'\|\||##' -lanE'$.>1 or $" ="||",next; say "#F[0,$_,$_+4]" for 1..4' file
perl -F'\|\|' -lane '#a=split(/##/,$F[1]); #b=split(/##/,$F[2]); print "$F[0]||$a[$_]||$b[$_]" foreach 0..$#a;' file
Output:
ID || DATE || AMOUNT
XX||20130801||100
XX||20130901||200
XX||20131001||300
XX||20131101||400
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am editing a Wiki page on GitHub using the Markdown edit mode and trying to insert a block of code form a shell script as follows:
```
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u#\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u#\h:\w\$ '
fi
```
However, the block ends up looking like this instead:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[SAME-43-CHAR-SEQUENCE[01;32m\]\u#\h\[SAME-43-CHAR-SEQUENCE[00m\]:\[SAME-43-CHAR-SEQUENCE[01;34m\]\w\[SAME-43-CHAR-SEQUENCE[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u#\h:\w\$ '
fi
So it looks like it's interpreting the char sequence \033 as some sort of code SAME-43-CHAR-SEQUENCE which looks like some sort of UUID. How can I avoid that? Thx
Escaping the slash with another slash seems to work.
So, change \033 to \\033
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\\033[01;32m\]\u#\h\[\\033[00m\]:\[\\033[01;34m\]\w\[\\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u#\h:\w\$ '
fi