Search Results

Search: Posts Made By: Yoda
11,881
Posted By Yoda
One approach is to use a for loop to open one...
One approach is to use a for loop to open one file at a time, modify and redirect the output to a temporary file, rename the temporary file back to original file:-
for file in *.txt; do awk -F,...
19,337
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)...
11,389
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)

...
4,037
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 (( ))...
11,485
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...
4,250
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...
5,300
Posted By Yoda
Using awk:- awk ' NF { ...
Using awk:-
awk '
NF {
SN = $0
sub(/\.[^.]*$/,X,SN)
++A[SN]
}
END {
for ( k in A )
...
5,913
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)
...
6,689
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
5,913
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] <=...
7,060
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
13,530
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))
7,896
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
13,530
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),...
11,151
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%%=*}"
...
4,544
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
11,743
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
16,746
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...
4,747
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
1,969
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:
...
4,552
Posted By Yoda
Try:- sed 's#\([|]\)\([...
Try:-
sed 's#\([|]\)\([ ]*\)\([|]\)#\10\2#;s#\([ ]*\)\([^ ]*\)\([ ]*\)#\2#g' file
3,516
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 =...
1,799
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...
13,327
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...
13,327
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.
Showing results 1 to 25 of 500

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