Search Results

Search: Posts Made By: kshitij
2,121
Posted By RudiC
How about awk 'NR == 1 {L = index ($0, "r") -...
How about
awk 'NR == 1 {L = index ($0, "r") - 1} {T = substr ($0, L); gsub (/./, "& ", T); print substr ($0, 1, L), T}' file
r s ...
6,095
Posted By RudiC
Your post headings are somewhat contradictory. If...
Your post headings are somewhat contradictory. If happy with awk and not insist on TCL, try
awk '
NR < 4 {if (NR == 1) ST = index ($0, "p")
for (i=ST; i<=NF; i+=2) P[i] =...
3,049
Posted By RudiC
Your input file is not too consistent in its...
Your input file is not too consistent in its usage of spaces as field separators. It has one or two between fields, one up to six from BOL to $2 if $1 is missing, and zero or one at EOL. That's what ...
3,049
Posted By RavinderSingh13
Hello kshitij, Could you please try...
Hello kshitij,

Could you please try following.


awk '
FNR==NR{
if($0~/^[0-9]+/){
++count
}
sum[count]+=$NF
next
}
/^[0-9]+/{
print $0,sum[++var]
next
}
1
' ...
4,087
Posted By Chubler_XL
I would use capture groups like this: sed...
I would use capture groups like this:


sed 's/\([0-9]\)[0-9]\([0-9]\)$/\1\2/' infile
4,087
Posted By Chubler_XL
The example file only has 3 fields not 7. ...
The example file only has 3 fields not 7.

awk - remove last two digits from field 3:
awk '{gsub(/[0-9][0-9]$/,"",$3)} 1' infile

sed - remove last two digits on line
sed 's/[0-9][0-9]$//'...
4,087
Posted By RudiC
Help me out - I see three fields only, not 7. To...
Help me out - I see three fields only, not 7. To remove two trailing digits from $3, try
awk '{sub (/..$/, _, $3)} 1' file
3,777
Posted By Scrutinizer
That is the case with sed, but with awk it can be...
That is the case with sed, but with awk it can be on the same line.

$ printf '1 2\n2 3\n3 4\n' | sed -n '/1/,/2/p'
1 2
2 3

$ printf '1 2\n2 3\n3 4\n' | awk '/1/,/2/'
1 2
3,777
Posted By MadeInGermany
A range must span over two (or more) lines. ...
A range must span over two (or more) lines.
With a status variable it may end on the same line:
awk '/Umbist_reverse_inst/ {r=1}; r {gsub(/\(\)/,"")}; /\);/ {r=0}; 1' list
If the start pattern is...
3,777
Posted By Scrutinizer
I suggest using a range expression, so that all...
I suggest using a range expression, so that all replacements occur over all lines. Try:
awk '/Umbist_reverse_inst/,/\);/{gsub(/\(\)/,"")}1' list
Also, the parentheses need to be escaped, since they...
7,734
Posted By Chubler_XL
You could split on newline before doing a foreach...
You could split on newline before doing a foreach like this:

foreach p [ split $var4 "\n" ] {
puts $p
}
3,326
Posted By RudiC
Please check your arithmetics for the SUM of...
Please check your arithmetics for the SUM of pat9.
I can't see where you comply with the specified weight of .25.


Tryawk -F, -vOFS=, '
NR == 1 {
$1 = sprintf ("%-25s", $1)
...
1,063
Posted By RudiC
How about sed -e '/chip top alist/,/));/{/));/...
How about
sed -e '/chip top alist/,/));/{/));/ r file2' -e'}; ' file1
Make sure your regex matches the file's contents (it doesn't in port#1)
1,063
Posted By RudiC
Try sed -e '/));/ {p;r file2' -e'}; ' file1
Try

sed -e '/));/ {p;r file2' -e'}; ' file1
1,596
Posted By RudiC
How aboutawk ' FNR == NR {INS=INS DL $0 ...
How aboutawk '
FNR == NR {INS=INS DL $0
DL = ORS
next
}
/^memP/ {C = 1
}
C {BRACNT += gsub (/{/,...
1,335
Posted By Don Cragun
If there can also be cases where there is no...
If there can also be cases where there is no other word following your matched string and you want to remove that as well, you might want something more like:
sed -s 's/_bbox[^ ]* / /' -s 's/_bbox[^...
1,335
Posted By zaxxon
$ sed 's/_bbox[^ ]* / /' infile addfd_mjlala...
$ sed 's/_bbox[^ ]* / /' infile
addfd_mjlala kksks sksks ks
annsns (sksksk ksks )
adnndn_nsns (( jsjsdj sjsj )
malm_dkdm lsls lsl
mdndk_mkmd_dkd [jkssk jsjs[]
ksksk skksk ((jsjsj jsjsj )

...
1,448
Posted By rdrtx1
try also: awk -F, '{f=0; for...
try also:
awk -F, '{f=0; for (i=1;i<=NF;i++){a=$i;if(!f && a+=0)f=i} ; if ($f<100) $f="witdh=\"100\" " $f} 1' OFS=, infile
1,448
Posted By Scrutinizer
Or adjusting your original sed script: sed...
Or adjusting your original sed script:
sed 's/[9][0-9]\.[0-9]*/width="100" &/g' file
1,448
Posted By Akshay Hegde
Try : $ cat file ahsh,90.82,add,32424,ahha...
Try :

$ cat file
ahsh,90.82,add,32424,ahha
hhdh,98.89,hdhdh,92728,neha
hshs,you,97.7,hdhdhd,are,a
jsjsj,wonderful,9788,79.9,aheh
ahdh,95.5,girl, 2737,jolll

$ awk -F,...
1,448
Posted By clx
Which column to refer to ? You have 2nd have 3rd...
Which column to refer to ? You have 2nd have 3rd column in your case.
3,252
Posted By Don Cragun
Here is a version of the script with comments: ...
Here is a version of the script with comments:
awk '
$1 ~ /^mod[12]$/ {
# If the 1st field on a line is "mod1" or "mod2", note that we need to
# add text to the next line containing ");".
add...
3,252
Posted By protocomm
If i understand, the AND && is an logical and...
If i understand, the AND && is an logical and then 1 && 1=1 (1 && 0=0)
Showing results 1 to 23 of 23

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