use -w
For example, below command will find all lines which has exact word BIN
grep -r -w BIN ./
Useful link: https://stackoverflow.com/questions/19576292/display-exact-matches-only-with-grep
use -v option
Exclude word from a search
deepak@deepak-VirtualBox:~/promo/prometheus-exporter/test$ sudo docker ps -a | awk '{print $1}'
CONTAINER
21d5db04eaea
e7c06427b8d6
0dcef3b3911f
0a72cc9d3350
eacf70e19a53
6a64c2bf1904
b2425c4a3607
deepak@deepak-VirtualBox:~/promo/prometheus-exporter/test$ sudo docker ps -a | awk '{print $1}' | grep -v CONTA
21d5db04eaea
e7c06427b8d6
0dcef3b3911f
0a72cc9d3350
eacf70e19a53
6a64c2bf1904
b2425c4a3607
Useful link:https://stackoverflow.com/questions/4538253/how-can-i-exclude-one-word-with-grep
Use sed with ^
Append text in the beginning
root@ubuntu:/var# head batch_config_input.txt
set cli mode -color off
set ns param -httpPort 80 -cip ENABLED header
add ns ip 192.168.1.137 255.255.255.0 -type mip -telnet enabled -ssh enabled -mgmtAccess ENABLED
add ntp server ntp.com
rm arp -all
enable ns mode L2
enable ns feature LB
enable ns mode FR
enable ns mode CKA
enable ns mode TCPB
root@ubuntu:/var# sed 's/^/cli_script.sh \"/g' batch_config_input.txt | more
cli_script.sh "set cli mode -color off
cli_script.sh "set ns param -httpPort 80 -cip ENABLED header
cli_script.sh "add ns ip 192.168.1.137 255.255.255.0 -type mip -telnet enabled -ssh enabled -mgmtAccess ENABLED
cli_script.sh "add ntp server ntp.com
cli_script.sh "rm arp -all
Useful link: https://stackoverflow.com/questions/4080526/using-sed-to-insert-text-at-the-beginning-of-each-line
Use sed with $
#find . -type f -name '*.cpp' | xargs sed -i '' 's/lstrm_logger::loglevels::info/lstrm_logger::loglevels::debug/g'
Refer: https://stackoverflow.com/questions/12696125/sed-edit-file-in-place
Append text in the end of line
root@ubuntu:/var# head op
cli_script.sh "set cli mode -color off
cli_script.sh "set ns param -httpPort 80 -cip ENABLED header
cli_script.sh "add ns ip 192.168.1.137 255.255.255.0 -type mip -telnet enabled -ssh enabled -mgmtAccess ENABLED
cli_script.sh "add ntp server ntp.com
cli_script.sh "rm arp -all
cli_script.sh "enable ns mode L2
cli_script.sh "enable ns feature LB
cli_script.sh "enable ns mode FR
cli_script.sh "enable ns mode CKA
cli_script.sh "enable ns mode TCPB
root@ubuntu:/var# sed 's/$/\" /g' op | more
cli_script.sh "set cli mode -color off"
cli_script.sh "set ns param -httpPort 80 -cip ENABLED header"
cli_script.sh "add ns ip 192.168.1.137 255.255.255.0 -type mip -telnet enabled -ssh enabled -mgmtAccess ENABLED"