Search Results

Search: Posts Made By: RudiC
79
Posted By RudiC
How about awk '/PROTOBUF_DIRS/ && match ($0,...
How about
awk '/PROTOBUF_DIRS/ && match ($0, /PXC[^_]*_1/) {print substr ($0, RSTART, RLENGTH)}' *.spec *.mkawk unfortunately lacks both the -r (--recursive) and the --include options that grep...
Forum: Shell Programming and Scripting 15 Hours Ago
79
Posted By RudiC
There seems to be a mixup between shell globs and...
There seems to be a mixup between shell globs and grep / regex patterns. Try grep 'body.*.xml'.


Or, recent bashes provide "extended pattern matching" if the extglob shell option is set:
shopt...
242
Posted By RudiC
I'm afraid, no. You've been shown in your other...
I'm afraid, no. You've been shown in your other thread (https://www.unix.com/303040608-post2.html) that division by 0 is possible in your context and the reason therefor. And, looking at your sample...
129
Posted By RudiC
Please answer the questions raised by Peasant. ...
Please answer the questions raised by Peasant.



All sed command operate on the pattern space; hold space is just a bucket for intermediate storage. Your code snippet swaps the line just read...
197
Posted By RudiC
How about grep -o...
How about
grep -o 'filename-[[:digit:].]*.tar.gz' file
filename-1.0.0.tar.gz
293
Posted By RudiC
Would this come close? grep -offile1 file2 |...
Would this come close?

grep -offile1 file2 | sort | uniq -c
2 god
1 pod
2 rod

--- Post updated at 16:24 ---

Hoppla - didn't take your thread title into account. Try this...
254
Posted By RudiC
Not sure I understand your request. Does this...
Not sure I understand your request. Does this work for your scenario 1 2?
echo "${STRING//,/$'\n'}" | awk -F: 'FNR==NR {T[$1,$2] = $0; next} ($1,$2) in T {$0 = T[$1,$2]} 1' - file
218
Posted By RudiC
How about lsblk -r -oname? From man lsblk:
How about
lsblk -r -oname? From man lsblk:
279
Posted By RudiC
Close to impossible. If installed and on the...
Close to impossible. If installed and on the PATH, bash wouldn't say that.
421
Posted By RudiC
NA was not specified. Try awk -F/ ' NR == 1 ...
NA was not specified. Try
awk -F/ '
NR == 1 {printf "Sl#,VideoName,BitRate"
}
FNR == NR {PRM[NR] = "( |no-)" $0 "=*[^ /]*"
MX = NR
...
421
Posted By RudiC
Try awk -F/ ' NR == 1 {printf...
Try
awk -F/ '
NR == 1 {printf "Sl#,VideoName,BitRate"
}
FNR == NR {PRM[NR] = "( |no-)" $0 "=*[^ /]*"
MX = NR
printf ",%s", $0
...
308
Posted By RudiC
In the END section, you're using b as the loop...
In the END section, you're using b as the loop variable but use $1 for building the indices. Won't fly.
And, if one or more of the categories don't exist for a student, their total array element...
430
Posted By RudiC
How about awk '/^>/ {$0 = $0 "" ++SUFF[$0]} 1'...
How about
awk '/^>/ {$0 = $0 "" ++SUFF[$0]} 1' file
332
Posted By RudiC
Try awk '/SAMPLE/ {printf "%s", $2; next} {$0 =...
Try
awk '/SAMPLE/ {printf "%s", $2; next} {$0 = "\t" $0; print}' file
442
Posted By RudiC
That mountpoint variable is not empty but holds...
That mountpoint variable is not empty but holds "". Change the if test to
if [ "$mountpoint" != \"\" ]; and it will fly...


EDIT: BTW, running awk 6 times per line to extract some variables is...
350
Posted By RudiC
You didn't say so in your spec... How about ...
You didn't say so in your spec...

How about

awk '
BEGIN {FS = ","
}
{for (i=1; i <= NF; i++) {if ($i<10) T = $i
else ...
350
Posted By RudiC
Try awk -F, ' {for (i=1; i <= NF;...
Try
awk -F, '
{for (i=1; i <= NF; i++) print $i<10?$i:10
}
' file
5
10
10
10
8
3
9
10
10
3
10
338
Posted By RudiC
That's a matter of logics, style, and personal...
That's a matter of logics, style, and personal taste. Use consistent indentation, keep blocks together, try to find some meaningful nomenclature for variables and functions.

awk -F',' '
/^ADD/ ...
332
Posted By RudiC
Try awk '{ORS = RS} /SAMPLE/ {sub ($1 FS, "");...
Try
awk '{ORS = RS} /SAMPLE/ {sub ($1 FS, ""); ORS = FS} 1' file
494
Posted By RudiC
None of the dates nor even times in your data...
None of the dates nor even times in your data samples will match the regexes you posted. Assuming all records will be terminated by a } , try (with your sample data in post #1)

sed -n...
460
Posted By RudiC
man lsb_release might help. E.g. $ lsb_release...
man lsb_release might help. E.g.
$ lsb_release -is
UbuntuA case statement could be used
case $(lsb_release -is) in
red*) # run red hat command
;;
Ubu*) # run ubuntu command...
460
Posted By RudiC
How about the lsb_release -a command?
How about the

lsb_release -a
command?
158
Posted By RudiC
Try awk ' /^ *Fatal/,/^ *Client/ {if...
Try
awk '
/^ *Fatal/,/^ *Client/ {if (/Time/) printf "^%s", $0
if (/Client/) {printf "^%s", $0
getline
...
386
Posted By RudiC
Your commands won't work; you need at least e.g....
Your commands won't work; you need at least e.g. "command substitution".
Try
APP=$(application --version 2>/dev/null || echo "not installed") Be aware that not all applications / tools offer a...
158
Posted By RudiC
Your script seems a bit intricate. E.g. when...
Your script seems a bit intricate. E.g. when using the > redirection, you don't need to create / truncate the file upfront. And, with that many temp files, there must be a better approach. How far...
Showing results 1 to 25 of 500

 

Featured Tech Videos

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