Search Results

Search: Posts Made By: green_k
5,696
Posted By RavinderSingh13
Hello green_k, Could you please try...
Hello green_k,

Could you please try following.


awk '
/^\[/{
if(count){
for(i=1;i<=count;i++){
print val,a[i],count
}
}
val=$0
count=""
next
}
{
...
5,696
Posted By RavinderSingh13
Hello green_k, Could you please try...
Hello green_k,

Could you please try following.


awk '/^\[/{val=$0;next} {print val,$0}' Input_file


On Sun o.s use nawk in place of awk.

Thanks,
R. Singh
8,450
Posted By MadeInGermany
Some awk versions have a problem with parsing a...
Some awk versions have a problem with parsing a complicated FS.
The following variant takes a simple FS:
awk -v want="CITY,REGION,STREET" '
function prnsection() {
if (length(section)) {
...
8,450
Posted By Chubler_XL
On Sun OS you need to use nawk or...
On Sun OS you need to use nawk or /usr/xpg4/bin/awk as the legacy Solaris awk is missing many POSIX features.
8,450
Posted By Chubler_XL
Glad to explain what is going on in this code. ...
Glad to explain what is going on in this code. Working thru and understanding is a great way to improve your awk skills.

Field separator RE [=\\][]

This is a simple bracket [] expression and...
8,450
Posted By Chubler_XL
And another awk approach: awk -v...
And another awk approach:

awk -v want="VALUE1,VALUE2,VALUE3" -F'[=\\][]' '
function prnsection(i) {
if(length(section)) {
printf "%s",section;
for(i=1;i in keypos;i++) {
...
8,450
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...
2,496
Posted By Chubler_XL
Not quite there $1 contains the variable name and...
Not quite there $1 contains the variable name and is overwritten with "=" newvalue, try:

awk -F= -v var="$new_value" '/ABCD/ {$2 = var} 1' OFS== file > new_file
2,496
Posted By vgersh99
simplified and fixed: awk -F= -v...
simplified and fixed:

awk -F= -v var="$new_value" '/ABCD/ {$1= "=" var} 1' file > new_file
2,496
Posted By Scrutinizer
You can redirect the output to a new file. If ok...
You can redirect the output to a new file. If ok you can replace the old file with the new file:

nawk -F"=" '/ABCD/ {print $1"=value"}' file > newfile
1,967
Posted By MadeInGermany
"collating sequence" is the key! While most...
"collating sequence" is the key!
While most language (locale) settings in Unix are based on the ASCII sequence (numbers before characters), IBM seems to stick to the EBCDIC sequence (numbers after...
3,453
Posted By nezabudka
Hi Don, thanks for the explanation. awk 'BEGIN...
Hi Don, thanks for the explanation.
awk 'BEGIN {FS=OFS=","} /^T/ {$2=length(A)} !A[$0]++'
3,453
Posted By Don Cragun
Hi nezabudka, Nice approach. My code counts...
Hi nezabudka,
Nice approach. My code counts the number of lines output and ignores the value originally found in the "T" line field #2; your code subtracts the number of duplicates found.

If...
3,453
Posted By nezabudka
awk -F, '/^T/ {for(i in A) sum+=(A[i]-1);...
awk -F, '/^T/ {for(i in A) sum+=(A[i]-1); $2=$2-sum} !A[$0]++' file
3,453
Posted By Don Cragun
I'm always glad to have helped. With the sample...
I'm always glad to have helped. With the sample data you provided, the following would also work:
/usr/xpg4/bin/awk '
BEGIN { FS = OFS = ","
}
$1 == "D" {
if($0 in a)
next
a[$0]...
3,453
Posted By Don Cragun
Your description and code are not clear enough to...
Your description and code are not clear enough to be sure that this is what you want, but it works with the sample data provided:
awk '
BEGIN { FS = OFS = ","
}
$1 == "D" {
if($2 in a)
next...
1,033
Posted By bakunin
That depends - among other things - on what is in...
That depends - among other things - on what is in ~/.profile. One conceivable cause could be: $# is the number of (commandline) parameters the current process got. i.e. Consider this script:

#!...
1,033
Posted By vgersh99
when you say that it doesn't run, what does it...
when you say that it doesn't run, what does it mean? Any error messages? Anything get output?
Please post the first 10 lines of the script using code tags.
2,579
Posted By RudiC
Methinks you mean "indent", and you want to...
Methinks you mean "indent", and you want to suppress all entries with one or two spaces indentation? Why is auto_joba-bx (three leading spaces) missing in your sample result? How far would awk...
691
Posted By RavinderSingh13
Hello green_k, \\( means escape \ to...
Hello green_k,

\\( means escape \ to remove its special meaning. If you will put ( without \ will be treated as sub's starting ( parenthesis and it will give error.

Thanks,
R. Singh
691
Posted By MadeInGermany
It is because awk substitutes \ in strings. For...
It is because awk substitutes \ in strings. For example
nawk 'BEGIN {print "\a"}' </dev/null
nawk 'BEGIN {print "\b"}' </dev/nullSo within " " you need \\ for a literal \
Therefore, you better...
1,215
Posted By RudiC
Thanks, RavinderSingh13, for this explanation....
Thanks, RavinderSingh13, for this explanation. Small, nit-picking side remark: Nothing can be "greater than" AND "equal to" something, that's mutually exclusive. "Greater than or equal" would...
1,215
Posted By RavinderSingh13
Hello green_k, Welcome to UNIX and Linux...
Hello green_k,

Welcome to UNIX and Linux forums, hope you will enjoy sharing and learning knowledge here. Following explanation may help you in your question.

awk 'NF==1{ ...
Showing results 1 to 23 of 23

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