Search Results

Search: Posts Made By: dae
1,227
Posted By Scrutinizer
If you want to assign it all to one variable and...
If you want to assign it all to one variable and then use that value in a loop?
Try:
while IFS=/ read v_LstStdCdhId rest
do
if [[ $rest == *CD/39/AT/CDH_BV_ODS* ]]; then
echo...
1,227
Posted By RudiC
Try VAR=$(awk -F"/" '/CD\/39\/AT\/CDH_BV_ODS/...
Try VAR=$(awk -F"/" '/CD\/39\/AT\/CDH_BV_ODS/ {print $1 FS}' Bteq_Xport_GetLstStdViewToBuild__1274.txt) Can't be tested as the input file has not been posted.
1,289
Posted By MadeInGermany
awk '{ORS=sub(/\r$/,X)?X:RS}1' filename The...
awk '{ORS=sub(/\r$/,X)?X:RS}1' filename
The previous solution works with GNU(Linux) sed only. A Unix sed does not have \r.
1,289
Posted By neutronscott
mute@zbox:~$ sed '/\r$/{N;s/\r\n//}' 4_test.csv ...
mute@zbox:~$ sed '/\r$/{N;s/\r\n//}' 4_test.csv
123456
7890AB


I'm usually an awk guy myself but this seemed worthy
1,289
Posted By Yoda
gawk '!/\r/{ORS=RS}/\r/{ORS=X}{gsub(/\r/,X)}1'...
gawk '!/\r/{ORS=RS}/\r/{ORS=X}{gsub(/\r/,X)}1' filename
1,705
Posted By Scrutinizer
As Don noted earlier, you did not apply my...
As Don noted earlier, you did not apply my suggestion. Look carefully: the second brace is in the wrong place:

wrong:
done
}
echo "- OUTSIDE WHILE:var:$var"
}

right:
done
...
1,705
Posted By Peasant
In the cat ... | while read you should see...
In the cat ... | while read you should see another pid while doing ps -ef | grep <your script pid>.
Another pid will be subshell pid with your script PID as parent.

For instance :


echo $$...
1,705
Posted By Don Cragun
You did not apply Scrutinizer's suggestion. And,...
You did not apply Scrutinizer's suggestion. And, a subshell and a separate process are two distinct things. And, again, the response is exactly the same. Using cat and a pipeline to feed input...
1,705
Posted By jgt
This thread may help you...
This thread may help you https://www.unix.com/302912242-post1.html
1,705
Posted By stomp
If you do not have a file but a command to be...
If you do not have a file but a command to be processed in the loop the corresponding construct will be helpful.

Instead of < file use < <( command )
1,705
Posted By Scrutinizer
A way to get around this (for demonstration sake,...
A way to get around this (for demonstration sake, because done < STG_INSTNCE_COMPLTED_01_451_20170112193018.log
is the superior approach to UUOC and there are better ways than using the grep -i...
1,705
Posted By Peasant
In the first example, pipe | creates a subshell...
In the first example, pipe | creates a subshell outside your current shell to execute a loop.
After the while loop is done, var is 0 in your current shell, since the increment was done in...
940
Posted By Chrismcq
Hi - I may be missing the point here, but if it...
Hi - I may be missing the point here, but if it is only the first update line that you are interested in, you could simply do the following :-

grep "Update completed" MyLogFile | head -1
Is this...
940
Posted By vgersh99
something along these lines: awk ' ...
something along these lines:

awk '
/^UPDATE/ {type=1;next}
type==1 && /Update completed/ { print "Updated rows: " (($4=="No")?0:$4); type=0}
' myFile
2,081
Posted By RudiC
Well, I hope I can explain the behaviour...
Well, I hope I can explain the behaviour adequately, but mayhap the other experts in here may jump in and correct/improve my comments...

shells, when expanding a line, and IFS is defined as the...
2,081
Posted By RudiC
Actually, this might work as well: eval...
Actually, this might work as well:
eval tgtfile=\""$(cat $srcfile)"\"
2,081
Posted By RudiC
How about while read line; do eval...
How about
while read line; do eval tgtfile=\""${tgtfile}"$line$'\n'\"; done < $srcfile
2,081
Posted By Scrutinizer
Well, I am afraid I really did not read you post...
Well, I am afraid I really did not read you post well enough..

Try this instead, with the usual security caveats that come with the use of eval, especially in combination with environment...
2,081
Posted By Scrutinizer
You are using eval on the contents of an input...
You are using eval on the contents of an input which may not only creates a potential security risk, it also does not really make sense here since it interprets its arguments as shell commands and in...
2,081
Posted By durden_tyler
$ $ cat dae2.txt DELETE FROM ...
$
$ cat dae2.txt
DELETE FROM CDH_STGN_${ENV1}.T1
;
INSERT INTO CDH_STGN_${ENV2}.T2
(
...
...
2,315
Posted By Don Cragun
Hi R. Singh, Note that you can easily put...
Hi R. Singh,
Note that you can easily put comments on multiple lines... You just have to put a # somewhere on each line before the continued comment text as in:
awk -v RP="$var" ' ...
2,315
Posted By RavinderSingh13
Hello dae, I thought you have to read...
Hello dae,

I thought you have to read variables from file, so I have given solution like that. Following explanation for sir Rudi's solution may help you in same.

awk -v RP="$var" ' ...
2,315
Posted By RudiC
or even awk -v RP="$var" ' BEGIN {for...
or even
awk -v RP="$var" '
BEGIN {for (n=split(RP, T, "[\n:]"); n>0; n-=2) REPL[T[n-1]] = T[n]
}
{for (r in REPL) sub (r, REPL[r])
}
1
' file
2,315
Posted By RavinderSingh13
Hello dae, Could you please try following...
Hello dae,

Could you please try following and let me know if this helps.

awk 'FNR==NR{A[$1]=$2;next} {for(i in A){match($0,i);if(substr($0,RSTART,RLENGTH)){gsub(i,A[i],$0)}};print}' FS=":"...
17,104
Posted By Don Cragun
You could also try one of these three portable...
You could also try one of these three portable ways to do it. (Note that the behavior of echo -e is not defined by the standards and varies from shell to shell and operating system to operating...
Showing results 1 to 25 of 41

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