Search Results

Search: Posts Made By: Jotne
40,719
Posted By Jotne
And I see it works fine on multiple lines to...
And I see it works fine on multiple lines to :)echo "toy
home" | rev
yot
emoh

If it cant be done with awk, its not worth doing it ;)
1,744
Posted By Jotne
This works. ps | awk "{print $var}" Single...
This works.
ps | awk "{print $var}"

Single quote does not expand variable.
11,223
Posted By Jotne
Since I do not like to use bc because its not in...
Since I do not like to use bc because its not in all image. And normal I use bash. To do use math I use awk. This should work in most image.
Sed is not tool for math, so I do not see any reason...
1,500
Posted By Jotne
Some more awk awk -F"sip:|@" '{print $2}' file ...
Some more awk
awk -F"sip:|@" '{print $2}' file

gnu awk
awk '{print gensub(/.*sip:(.*)@.*/,"\\1","g")}' file
4,719
Posted By Jotne
Its not a good habit to use _ as an variable. ...
Its not a good habit to use _ as an variable. New user would have problem understanding what is going on.
Change it to some like
awk -F, '{arr[$3]=arr[$3]?arr[$3] OFS $2:$1 FS $2} END {for(i in...
1,213
Posted By Jotne
Your problem with this: awk...
Your problem with this: awk '/unburnt:.*burnt:/{Tu=$6;Tb=$NF}END{print Tu, Tb}' star.log is that you do the print in the END section. This will just print one instance.
Change it to:
awk...
6,146
Posted By Jotne
awk -F"[ =]" ' #setting the field separator to...
awk -F"[ =]" ' #setting the field separator to space or equal
/WORD1/ { #search for lines containing "WORD1"
print $3 #print filed number 3
}' file
2,502
Posted By Jotne
This was very interesting, and an eye opener. I...
This was very interesting, and an eye opener. I have never tested this, just thought i many be solver to run ting in loop. This prove it many be wrong.
Thanks for taking time to test. :)
3,473
Posted By Jotne
Why not use awk??? awk is a good tool for this...
Why not use awk???
awk is a good tool for this job. Here is another version.
echo a,b,c,d,e,f,g,h,i | awk 'NR>5 && $1~/f/ {print "yes"}' RS=,
yes
This prints yes if an f is found after 5th ,
2,502
Posted By Jotne
I try to avoid loops in awk to speed things up. ...
I try to avoid loops in awk to speed things up. If you have gnu awk, you can do this:
awk '{a+=$1} END {print a}' RS=" |\n" file?
1779
If you like to store this into a variable do this:...
8,785
Posted By Jotne
Using awk and getting text at correct position...
Using awk and getting text at correct position (tabbed)
awk -F"\t" '/parent::__construct()/ {$0=$0"\n";for (i=1;i<NF;i++)t=t "\t";$0=$0 t "NEW STRING"}1' application/core/MY_Controller.php
<?php ...
6,146
Posted By Jotne
awk -F"[ =]" '/WORD1/ {print $3}' file ...
awk -F"[ =]" '/WORD1/ {print $3}' file
value1-idkey1
1,414
Posted By Jotne
EDIT: Did not fix the space. Here is another...
EDIT:
Did not fix the space.
Here is another version that should work.
awk -F/ '{print $NF"§"$0}' file | sort | awk -F§ '{print $2}'
Path=/home/pikamon/Desktop/ABC;...
2,549
Posted By Jotne
Using awk awk 'NR%2==0' RS=\' file ...
Using awk
awk 'NR%2==0' RS=\' file
/project/cars/version/scripts/
/project/cars/version/scripts/y.txt
/project/cars/version/scripts/x.txt
8,618
Posted By Jotne
To get many of the awk version to work with code...
To get many of the awk version to work with code like this [0-9]{3}, you need to add --posix.
Eks
awk --posix '/^[0-9-]{3}/' file

This should make the original code to work.
1,423
Posted By Jotne
And if your terminal support 256 colors, try this...
And if your terminal support 256 colors, try this script:
#!/bin/bash
#
# generates an 8 bit color table (256 colors) for reference,
# using the ANSI CSI+SGR \e[48;5;${val}m for background and
#...
3,124
Posted By Jotne
@disedorgue Sed solution does not work with...
@disedorgue
Sed solution does not work with this line:
aa,"bb,rr,ff","cc,aa",dd,ee gives aa,"bb,rr,ff","LQcc,aa",dd,ee
correct aa,"bb,rr,ff","cc,aa",LQdd,ee



Fixed my solution to handle...
1,038
Posted By Jotne
What is wrong with this post: ...
What is wrong with this post:
https://www.unix.com/shell-programming-scripting/234857-shell-script-extract-data-csv-file.html
1,623
Posted By Jotne
With 40 post here, you should now how to use Code...
With 40 post here, you should now how to use Code Tags

awk 'NR>=3 && NR<=5 {$0="OK "$0} 1'
surya
rama
OK ranga
OK laxman
OK rajesh
reddy
38,946
Posted By Jotne
Use google Or read section 43 here: Famous Awk...
Use google
Or read section 43 here: Famous Awk One-Liners Explained, Part II: Text Conversion and Substitution - good coders code, great reuse...
917
Posted By Jotne
awk -F"[][]" '{print $2}' /var/log/maillog ...
awk -F"[][]" '{print $2}' /var/log/maillog
55.66.77.88
6,225
Posted By Jotne
using awk awk...
using awk
awk '{match($0,"[0-9][0-9][0-9][0-9][0-9][0-9]",a);print a[0]}' test1.txt
370956

PS do not cat the file to sed/awk, add file behind, like my example.
1,385
Posted By Jotne
You did remove this OFS=","
You did remove this OFS=","
2,089
Posted By Jotne
Using or in regex $9~/regex1|regex2|regex3|.../
Using or in regex
$9~/regex1|regex2|regex3|.../
5,236
Posted By Jotne
This should work. No need print, since print $0...
This should work. No need print, since print $0 is default action.
awk -F\| '$9 ~ /\/.*[0-9]+/' file1 > file2

The * here \/* makes / optional. 0 or more hits. Remove this.
Same here:...
Showing results 1 to 25 of 201

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