7 Matching Annotations
- Feb 2022
-
learnbyexample.github.io learnbyexample.github.io
-
# line containing 'cake' but not 'at' # same as: grep 'cake' table.txt | grep -v 'at' # with PCRE: grep -P '^(?!.*at).*cake' table.txt $ awk '/cake/ && !/at/' table.txt blue cake mug shirt -7
It should be easier to use awk over bash, especiallly for AND conditions.
For example, for "line containing
cake
but notat
": * grep:grep 'cake' table.txt | grep -v 'at'
* grep with PCRE:grep -P '^(?!.*at).*cake' table.txt
* awk:awk '/cake/ && !/at/' table.txt
Tags
Annotators
URL
-
- Jul 2021
-
unix.stackexchange.com unix.stackexchange.com
-
sed appears to be able to do this much more efficiently if a large number of files are involved. awk may be easier to remember, but sed seems to be worth a sticky note in my brain.
-
- Mar 2021
-
askubuntu.com askubuntu.com
-
awk is my weapon of choice when it comes to text processing. Besides, it's syntax is close to C
-
$(awk -F= '/^Exec/||/^TryExec/ {print $2;exit}' /usr/share/applications/firefox.desktop)
-
- Feb 2021
-
-
To get all the processes spawned by a process the whole tree needs to be built. I used awk for that. At first it builds a hash array to contain all PID => ,child,child... . At the end it calls a recursive function to extract all the child processes of a given process. The result is passed to another ps to format the result.
-
- Oct 2018
-
stackoverflow.com stackoverflow.com
-
print every nth line into a row
-
- Jun 2017
-
coolshell.cn coolshell.cn
-
awk 101
-