Search Results

Search: Posts Made By: Yoda
1,058
Posted By Yoda
You can simply pass the variable value as a...
You can simply pass the variable value as a command line argument:-
python.py "${db}"
In you python program, you can use the sys.argv to accept and use argument:-

import sys

if len(sys.argv)...
2,781
Posted By Yoda
Here is an approach using nawk by checking each...
Here is an approach using nawk by checking each character:-
nawk '
{
for ( i = 1; i <= length; i++ )
{
c = substr($0,i,1)

...
719
Posted By Yoda
I noticed several syntax errors in your script. ...
I noticed several syntax errors in your script.


If and elif conditional expressions missing blank spaces
Use -eq instead for numerical comparison
One can increment variable within (( ))...
2,648
Posted By Yoda
Here is one approach using awk:- awk -F= ' ...
Here is one approach using awk:-
awk -F= '
/section/ {
sc = $1
S[sc]
next
}
/^VALUE/ {
A[sc FS $1] = $0...
871
Posted By Yoda
Your data appears to have variable number of...
Your data appears to have variable number of columns. The code you wrote will work if all rows in your input file has exactly three columns.

But if that is how your input data is, then one...
969
Posted By Yoda
Using awk:- awk ' NF { ...
Using awk:-
awk '
NF {
SN = $0
sub(/\.[^.]*$/,X,SN)
++A[SN]
}
END {
for ( k in A )
...
1,217
Posted By Yoda
I suppose then your input is not tab delimited,...
I suppose then your input is not tab delimited, try:-
awk '
NR == FNR {
A[$1] = $0
next
}
$1 in A {
split(A[$1], T)
...
1,307
Posted By Yoda
Set xtrace and verbose ON and run the script to...
Set xtrace and verbose ON and run the script to understand at which stage it is waiting.

#!/bin/ksh -xv
1,217
Posted By Yoda
Try:- awk -F'\t' ' NR == FNR { ...
Try:-

awk -F'\t' '
NR == FNR {
A[$1] = $0
next
}
$1 in A {
split(A[$1], T)
if ( T[2] >= $4 && T[3] <=...
1,350
Posted By Yoda
Another approach using awk:- awk...
Another approach using awk:-
awk '{t+=gsub(/\|/,"&")}t!=3{ORS=FS}t==3{ORS=RS;t=0}1' file
Forum: Programming 09-18-2019
4,416
Posted By Yoda
To see the output from program, you have to print...
To see the output from program, you have to print the output. I believe stdout is used internally for this function:-

print subprocess.check_output(shlex.split(command))
2,222
Posted By Yoda
You have to use a LOOP to fetch and print all of...
You have to use a LOOP to fetch and print all of them:-

BEGIN
OPEN C1;
LOOP
FETCH C1 into KS_UID;
EXIT WHEN C1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(KS_UID);
END LOOP;
CLOSE C1;
END;
/
Forum: Programming 09-18-2019
4,416
Posted By Yoda
It is also possible that the command that you are...
It is also possible that the command that you are running is sending the output to stderr instead of stdout

Try this instead:-

subprocess.check_output(shlex.split(command),...
3,615
Posted By Yoda
Using built-in parameter substitution...
Using built-in parameter substitution (https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/osmanagement/korn_shell_parmsub1.html):-

while read line
do
SOME_VAR="${line%%=*}"
...
1,270
Posted By Yoda
Variable name is case sensitive:- awk ' ...
Variable name is case sensitive:-
awk '
BEGIN {
print "<table>"
}
{
print "<tr>"
for ( i = 1; i <= NF; i++ )
...
Forum: What is on Your Mind? 09-06-2019
4,047
Posted By Yoda
This discussion forum was really instrumental in...
This discussion forum was really instrumental in helping me broaden my understanding about *nix systems.

I like to thank every Advisors and Moderators for their great efforts. Keep up the good...
Forum: Red Hat 04-22-2019
1,409
Posted By Yoda
Here are the different process state codes and...
Here are the different process state codes and description:-

D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to...
907
Posted By Yoda
Using shell built-ins:- while read line do ...
Using shell built-ins:-
while read line
do
for file in ${line//:/ }
do
print $file
done
done < data.txt

OR
tr ':' '\n' < data.txt
505
Posted By Yoda
If you have python installed, here is an...
If you have python installed, here is an approach:-
import datetime

def previous_weekday(day, weekday):
days_behind = weekday - day.weekday()
if days_behind >= 0:
...
366
Posted By Yoda
Try:- sed 's#\([|]\)\([...
Try:-
sed 's#\([|]\)\([ ]*\)\([|]\)#\10\2#;s#\([ ]*\)\([^ ]*\)\([ ]*\)#\2#g' file
647
Posted By Yoda
Please use code tags for code fragments. ...
Please use code tags for code fragments.

Your code is pretty much straightforward:-
# BEGIN Block
BEGIN {
i = 1 # Initialize i = 1
file =...
467
Posted By Yoda
Note that = is an assignment operator. It assigns...
Note that = is an assignment operator. It assigns the value of right side expression to left side.

But == is an equal to operator. It compares the value of both sides. Hence you have to use == in...
1,522
Posted By Yoda
You should ensure the here document is closed for...
You should ensure the here document is closed for both your SQL blocks:-
sqlplus -s /nolog << EOF
connect $conn_str;
whenever sqlerror exit sql.sqlcode;
set newpage 0;
SET PAGESIZE 0;
SET ECHO...
1,522
Posted By Yoda
File name is case sensitive:- spool v_out.txt ...
File name is case sensitive:-
spool v_out.txt
spool V_OUT.txt append
will create two different files.
1,522
Posted By Yoda
Note that SPOOL...
Note that SPOOL (https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12043.htm) has an APPEND option. So all you have to do is use it when you run your 2nd SQL:-
SPOOL v_out.txt APPEND
Showing results 1 to 25 of 500

 
All times are GMT -4. The time now is 08:08 AM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy