Unix/Linux Go Back    

Showing results 1 to 25 of 500
Search took 0.09 seconds.
Search: Posts Made By: RavinderSingh13
Forum: Shell Programming and Scripting Linux 4 Days Ago
Replies: 4
Views: 319
Posted By RavinderSingh13
Hello dnat, In case your Input_file is same...

Hello dnat,

In case your Input_file is same as shown sample then following may also help you on same.

awk '{printf("%s%s",$0!~/^abcd/?"":(FNR==1?"":ORS),$0)} END{if($0!~/^abcd/){print ""}}' ...
Forum: Shell Programming and Scripting Linux 5 Days Ago
Replies: 4
Views: 214
Posted By RavinderSingh13
Hello boncuk, Since you haven't given any...

Hello boncuk,

Since you haven't given any samples so can't test it, could you please try following and let me know if this helps you.

awk 'length($0)>21{exit} 1' Input_file
Thanks,
R. Singh
Forum: Shell Programming and Scripting Linux 5 Days Ago
Replies: 6
Views: 307
Posted By RavinderSingh13
Hello shekhar_4_u, If interested in awk then...

Hello shekhar_4_u,

If interested in awk then following may help you too on same.

awk -v s1="\""...
Forum: Shell Programming and Scripting Linux 1 Week Ago
Replies: 13
Views: 347
Posted By RavinderSingh13
Hello as7951, That's obvious because NONE...

Hello as7951,

That's obvious because NONE of them I believe are satisfying the conditions(since their difference is in range of +2 to -2, please check and let us know on same. Kindly check once...
Forum: Shell Programming and Scripting Linux 1 Week Ago
Replies: 13
Views: 347
Posted By RavinderSingh13
Hello as7951, Could you please check once if...

Hello as7951,

Could you please check once if your Input_file is having carriage characters by doing.

cat -v Input_file
In case it is there then try removing them by doing as follows.

tr...
Forum: Shell Programming and Scripting Linux 1 Week Ago
Replies: 13
Views: 347
Posted By RavinderSingh13
Hello as7951, Could you please try following...

Hello as7951,

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

awk -F"|" 'FNR==1{print $1,$2,$5;next} (($5-($1*$3))>=-2) && ((($1*$3)-$5)<=2){next} {print $0 " is bad, line...
Forum: UNIX for Beginners Questions & Answers Linux 1 Week Ago
Replies: 13
Views: 296
Posted By RavinderSingh13
Hello nextStep, Following awk may help you...

Hello nextStep,

Following awk may help you on same too.

awk 'match($0,/UA:MP:[a-zA-Z]+[0-9]+/) && !a[substr($0,RSTART,RLENGTH)]++{sub(/\[/,"",$1);sub(/\]/,"",$2);print...
Forum: Shell Programming and Scripting Linux 1 Week Ago
Replies: 4
Views: 258
Posted By RavinderSingh13
Hello cplusplus1, Could you please try...

Hello cplusplus1,

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

awk '{gsub(/^\||\|$/,"")} 1' Input_file > temp_file && mv temp_file Input_file
Thanks,
R. Singh
Forum: UNIX for Beginners Questions & Answers Linux 1 Week Ago
Replies: 13
Views: 296
Posted By RavinderSingh13
Hello nextStep, Following is the explanation...

Hello nextStep,

Following is the explanation may help you on same.


awk '
match($0,/UA:MP:[a-zA-Z]+[0-9]+/) && !a[substr($0,RSTART,RLENGTH)]++{ ##Using match utility of awk to match REGEX...
Forum: UNIX for Beginners Questions & Answers Linux 1 Week Ago
Replies: 13
Views: 296
Posted By RavinderSingh13
Hello nextStep, Could you please try...

Hello nextStep,

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

awk 'match($0,/UA:MP:[a-zA-Z]+[0-9]+/) && !a[substr($0,RSTART,RLENGTH)]++{print substr($0,RSTART,RLENGTH)}' ...
Forum: UNIX for Beginners Questions & Answers Linux 1 Week Ago
Replies: 2
Views: 204
Posted By RavinderSingh13
Hello vbabz, Welcome to UNIX and LINUX...

Hello vbabz,

Welcome to UNIX and LINUX forums. Kindly use code tags for your samples shown in your post. In case your actual Input_file is same as shown sample then following may help you on same....
Forum: UNIX for Beginners Questions & Answers Linux 1 Week Ago
Replies: 3
Views: 203
Posted By RavinderSingh13
Hello JSKBOS, Following may also help you on...

Hello JSKBOS,

Following may also help you on same.

awk '{printf("%s%s\n",FNR==1?"START OF LINE":"",$0)' Input_file
Thanks,
R. Singh
Forum: Shell Programming and Scripting Linux 1 Week Ago
Replies: 12
Views: 463
Posted By RavinderSingh13
Hello ranjancom2000, Could you please try...

Hello ranjancom2000,

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

awk 'FNR==NR{a[$3]=$0;next} {printf("%s %s\n",$1 in a?a[$1]:"Notfound",$0)}' Input_file1 Input_file2
...
Forum: Shell Programming and Scripting Linux 2 Weeks Ago
Replies: 5
Views: 243
Posted By RavinderSingh13
Hello schandra128, Following may help you on...

Hello schandra128,

Following may help you on same.

awk -F">R|<" '{val=$3>prev?$3:prev;prev=$3} END{print val}' Input_file
Thanks,
R. Singh
Forum: Shell Programming and Scripting Linux 2 Weeks Ago
Replies: 5
Views: 243
Posted By RavinderSingh13
Hello schandra128, In case your latest...

Hello schandra128,

In case your latest version is always coming on 2nd last line of Input_file then following may help you on same.

tail -2 Input_file | head -1
Thanks,
R. Singh
Forum: Shell Programming and Scripting Linux 2 Weeks Ago
Replies: 3
Views: 222
Posted By RavinderSingh13
Hello flamer, Welcome to UNIX and LINUX...

Hello flamer,

Welcome to UNIX and LINUX forums hope you will enjoy learning and sharing knowledge here. Since you have not shown any samples so couldn't test following code. Could you please try...
Forum: Shell Programming and Scripting Linux 2 Weeks Ago
Replies: 3
Views: 261
Posted By RavinderSingh13
Hello kartikirans, Could you please try...

Hello kartikirans,

Could you please try following and let me know if this helps you, not tested it since you haven't given sample output.

sed '/TimeRange/s/=.*/new_value/g' Input_file
...
Forum: Shell Programming and Scripting Linux 2 Weeks Ago
Replies: 5
Views: 247
Posted By RavinderSingh13
Hello jaapar, Following awk may also help...

Hello jaapar,

Following awk may also help you on same.

echo "User_Alias SYSTEM_ADMIN=xxxx1,xxxx2,xxxx3,xxxx4" | awk '{print $0",xxxx5"}'
Thanks,
R. singh
Forum: UNIX for Beginners Questions & Answers Linux 2 Weeks Ago
Replies: 2
Views: 208
Posted By RavinderSingh13
Hello mirwasim, You are using correct logic...

Hello mirwasim,

You are using correct logic but wrong field number, try following and let me know if this helps you.

awk '!a[$2]++' Input_file
Where $2 denotes 2nd field of the current line...
Forum: Shell Programming and Scripting Linux 3 Weeks Ago
Replies: 10
Views: 360
Posted By RavinderSingh13
Hello Geneanalyst, If your Input_file is...

Hello Geneanalyst,

If your Input_file is same as shown samples then following may help you on same.

awk 'FNR==NR&&FNR>1{a[$1]=$NF;next} FNR>1{if(a[$1]){$NF=$(NF-1)=""} else {$(NF-1)=OFS $(NF-1)...
Forum: Shell Programming and Scripting Linux 3 Weeks Ago
Replies: 10
Views: 360
Posted By RavinderSingh13
Hello Geneanalys, Could you please try...

Hello Geneanalys,

Could you please try following and let me know if this helps you. (tested with GNU awk)

awk 'FNR==NR{num=split($NF,array,"");for(i=1;i<=num;i++){val=val?val OFS...
Forum: UNIX for Beginners Questions & Answers Linux 04-11-2018
Replies: 5
Views: 215
Posted By RavinderSingh13
Hello RudiC, Good point :b: Then for these...

Hello RudiC,

Good point :b:
Then for these kind of scenarios following may help on same then.

awk -F"[ =]" '/^City/{val="";for(i=2;i<=NF-3;i++){val=val?val OFS $i:$i};print;next} {print val...
Forum: UNIX for Beginners Questions & Answers Linux 04-11-2018
Replies: 5
Views: 215
Posted By RavinderSingh13
Hello tech_frk, Could you please try...

Hello tech_frk,

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

awk -F"[ =]" '/^City/{val=$2;print;next} {print val "\t" $0}' Input_file
Thanks,
R. Singh
Forum: Shell Programming and Scripting Linux 04-09-2018
Replies: 2
Views: 124
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
Forum: Shell Programming and Scripting Linux 04-07-2018
Replies: 3
Views: 187
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 25 of 500

 


All times are GMT -4. The time now is 04:19 AM.