ou need a more specific expression. Try grep " OK$"
or grep "[0-9]* OK"
. You want to choose a pattern that matches what you want, but won’t match what you don’t want. That pattern will depend upon what your whole file contents might look like.
You can also do: grep -w "OK"
which will only match a whole word “OK”, such as “1 OK” but won’t match “1OK” or “OKFINE”.
$ cat test.txt | grep -w "OK" 1 OK 2 OK 4 OK
Related Posts:
- Display exact matches only with grep
- How to pretty print XML from the command line?
- What are file descriptors, explained in simple terms?
- How to kill a process running on particular port in Linux?
- How to split a delimited string into an array in awk?
- What does ^M character mean in Vim?
- What does it mean to write to stdout in C?
- What do ‘real’, ‘user’ and ‘sys’ mean in the output of time(1)?
- mkdir’s “-p” option
- wait(null) and wait(&status) C language and Status
- Shell script “for” loop syntax
- How to get the current directory in a C program?
- When could or should I use chmod g+s on a file or directory?
- How to Sum a column in AWK?
- Equivalent of *Nix ‘which’ command in PowerShell?
- What is the difference between SIGSTOP and SIGTSTP?
- How to colorize diff on the command line
- How to colorize diff on the command line
- How to read a file into a variable in shell?
- gpg decryption fails with no secret key error
- What is the difference between tar and zip?
- Display current path in terminal only
- What do the dup() and dup2() systems really do?
- What generates the “text file busy” message in Unix?
- Reasoning behind C sockets sockaddr and sockaddr_storage
- How can I send an email through the UNIX mailx command?
- Rename multiple files based on pattern in Unix
- What is the difference between a symbolic link and a hard link?
- SCP Permission denied (publickey). on EC2 only when using -r flag on directories
- binary operator expected error when checking if a file with full pathname exists
- What is special about /dev/tty?
- How do I do ‘mount –bind’ in /etc/fstab?
- How to read backward from the end of file in less or more?
- Getting the last match in a file using grep
- What is newline character — ‘\n’
- Why does ENOENT mean “No such file or directory”?
- sudo: npm: command not found
- How do I grep recursively?
- How do I grep recursively?
- What is the meaning of *nix?
- In the shell, what does ” 2>&1 ” mean?
- grep –ignore-case –only
- What are .a and .so files?
- How can I check if a directory exists in a Bash shell script?
- OS X: equivalent of Linux’s wget
- Connect: Socket operation on non-socket
- Connect: Socket operation on non-socket
- OS X: equivalent of Linux’s wget
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- SSH using python script
- How can I exclude directories from grep -R?
- How can I exclude directories from grep -R?
- What is a bus error? Is it different from a segmentation fault?
- Who can access a file with octal permissions “000” on Linux/UNIX?
- How to cat <
> a file containing code? - Extract file basename without path and extension in bash
- Which characters need to be escaped when using Bash?
- Diff command along with Grep gives “Binary file (standard input) matches”
- What is cp: cannot stat error in Unix, I get this error when trying to copy thing from one folder to another
- cp: missing destination file operand after
- What is a bus error? Is it different from a segmentation fault?
- How to download a file from server using SSH?
- What is the ASCII Code of ½?
- Get Unix timestamp with C++
- What is cp: cannot stat error in Unix, I get this error when trying to copy thing from one folder to another
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- What does `set -x` do?
- Command to change the default home directory of a user
- Is there any simple way to benchmark Python script?
- Sorting data based on second column of a file
- Variable interpolation in the shell
- Using ls to list directories and their total sizes
- Can’t remove a directory in Unix
- Syntax error near unexpected token ‘then’
- C fopen vs open
- What is `S_ISREG()`, and what does it do?
- Shell script not running, command not found
- Reaching EOF with fgets
- Using grep and ls -a commands
- Restarting cron after changing crontab file?
- Difference between sh and Bash
- What are the uses of the exec command in shell scripts?
- cd into directory without having permission
- grep for special characters in Unix
- How do I change my private key passphrase?
- How do I get the current Unix time in milliseconds in Bash?
- Copying a large directory tree locally? cp or rsync?
- Environment variables of a running process on Unix?
- When does /tmp get cleared?
- SSL Certificate Location on UNIX/Linux
- Is it possible to detach a process from its terminal? (Or, “I should have used screen!”) [duplicate]
- What does ‘set -e’ do, and why might it be considered dangerous?
- Meaning of directories on Unix and Unix like systems
- How to remove empty/blank lines from a file in Unix (including spaces)?
- How to forcibly close a socket in TIME_WAIT?
- How to get pid of just started process
- Can you have more than one ~/.ssh/config file?
- How to disable everything in crontab -l?
- How to sort ps output by process start time?
- How to check what port mysql is running on