Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*"
Favorites infavorites:mine
Status closed:yes
Types is:question
Exclude -[tag]
For more details on advanced search visit our help page
Results tagged with Search options user 119298

A pattern-directed scanning and processing language.

XXX and the pattern A for the real substitution. Similarly, for B. This does not handle your semi-nested `a*b`c* case. awk '{ str = $0 str = gensub(/(`[^`]*`|\*[^\*]*\*)/, "XXX\\1", "g", str); str …
answered May 13 '18 by meuh
If you want all lines with column 3 outside your limits then simply awk '$3>=210 || $3<=180 {print}' If you want just the first such line until the data is back inside the limits then: awk '$3 …
answered Jun 20 '16 by meuh
If your data is at fixed columns, you can ask awk to split at those column widths by setting FIELDWIDTHS. eg: awk ' BEGIN{ FIELDWIDTHS="4 10 8 10 8 6 99" } { printf "1=%s 2=%s 7=%s\n", $1, $2, $7 } ' gives 1=0 2=PATRAC_1 7=Not configure …
answered Jun 26 '15 by meuh
awk supports a regexp as field separator, replace your FS='|' setting with FS=' *\\| *' Note the need to escape the | as the strings is now a pattern. This does not handle whitespace at the start …
answered Dec 20 '17 by meuh
the arithmetic, then place it back in the string. For example, awk '{ n = split($0, d, /\/([0-9]+),/, s) print d[1] "/"(substr(s[1],2)+3)"," d[2] }' This uses gnu awk's split() function with … may appear several times in one line of your data, a better solution is to use match() to find only the last occurence and cut up the line using substr(): awk '{ match($0, /.*\/([0-9]+),/, m) a …
answered Jul 17 '17 by meuh
Your test $2 ~ /./ is always true, except when $2 is the empty string, ie when there is 0 or 1 field in the line. You should try $2 ~ /^.$/. You can also combine the grep and awk into one: awk '/^.M/ {print ($2 ~ /^.$/ ? $3 : $2)}' …
answered Apr 8 '16 by meuh
You can compare file timestamps directly in bash/zsh/ksh with the test operator -nt (newer-than). You can also use touch to set a time on a file, eg 0:00 for midnight today. So simply: touch -d '0:00 …
answered Jul 2 '15 by meuh
&&&/ so you have awk 'tolower($0) ~ /&&&key word&&&/ { p = ! p ; next }; p' text.txt You need single quotes because of the $0, the BEGIN block can be removed as variables are initialised by default to "" or 0 on first use, and {print} is the default action, as mentioned in the comments below. …
answered Apr 1 '16 by meuh
The meaning is data as opposed to constants, in the sense that "abc" or 88 or /a|b/ appearing in the awk program is a constant, but an awk variable contains data, or $0 contains data read from the … input. Data is not parsed, but constants in the body of the awk program text are. Say you want to match the input x+y...z where there are 1 or more y's so you need a regexp, but need to escape the …
answered Jul 16 '17 by meuh
Just for comparison, here is an non-expert perl version which gains a lot by being able to call a function from within a substitution. It is as if you could say gsub(regexp, call_function(matched_pa …
answered May 25 by meuh
Yes, if your awk has the system() function which can run commands: awk 'BEGIN{rc = system("test -t 1")}' rc will be the return code of the test. …
answered Apr 11 '16 by meuh
This works on your data. Perhaps you can give more info on what you need. awk -F'>' '/ResultDescxmlns/{ a = $2; getline b; getline c; printf "%s|%s|%s\n",c,b,a }' <file.txt When it matches a word …
answered Apr 25 '16 by meuh
(") string so your $i can be interpolated by the shell: awk '/^111$/{i=1;next} i && i++ <= '"$i" file Also, if your [header] strings are easily distinguishable from the data lines, you can just … use awk's ability to run a command when between two lines. Eg: seq 10 | awk '/6/,/9/{print}' will print lines 6 to 9. So instead of doing your own counting, and assuming [header1] is a typical header …
answered Jun 22 '15 by meuh
You should gain a lot by passing the log file just once through awk. This means combining all the regexps into one. If you don't want to do this in your scope.txt file, then do it before calling awk … . For example, sed <scope.txt 's|^/\^|(|; s|\$/$|)|; $!s/$/|/' | tr -d '\n' >pattern zcat $file | bro-cut -d | awk ' BEGIN{ getline pat <"pattern"; pat = "^(" pat ")$" } $3 ~ pat || $5 ~ pat …
answered Nov 27 '16 by meuh
If you know which field the timestamp is in, eg the 2nd word, you can use awk to do the conversion by getting it to call date: stdbuf -oL tail -f ... | awk -v timefield=2 '{ if($timefield ~ /[0-9 … know the field, or if it moves, you can try to match the timezone pattern on each word: awk '{ for(timefield = 1;timefield<=NF;timefield++) if($timefield ~ /^[0-9].*T.*Z$/){ "date …
answered Apr 7 '16 by meuh

15 30 50 per page