Visit The New, Modern Unix Linux Community

Search Results

Search: Posts Made By: Jotne
26,723
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,151
Posted By Jotne
This works. ps | awk "{print $var}" Single...
This works.
ps | awk "{print $var}"

Single quote does not expand variable.
7,283
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,009
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
1,969
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...
805
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...
2,920
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
1,375
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. :)
2,202
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 ,
1,375
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:...
5,759
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 ...
2,920
Posted By Jotne
awk -F"[ =]" '/WORD1/ {print $3}' file ...
awk -F"[ =]" '/WORD1/ {print $3}' file
value1-idkey1
738
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;...
1,764
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
4,227
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,054
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
#...
2,287
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...
749
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,038
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
29,509
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...
579
Posted By Jotne
awk -F"[][]" '{print $2}' /var/log/maillog ...
awk -F"[][]" '{print $2}' /var/log/maillog
55.66.77.88
1,498
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.
938
Posted By Jotne
You did remove this OFS=","
You did remove this OFS=","
1,521
Posted By Jotne
Using or in regex $9~/regex1|regex2|regex3|.../
Using or in regex
$9~/regex1|regex2|regex3|.../
2,942
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

 

Featured Tech Videos

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