0
votes
1answer
16 views

grep and search and replace in linux accepting parameters with /

I'm trying to find and replace the contents of a file using grep and sed. ```grep "#!/bin/bash" ./ | sed xargs -i 's/#!/bin/bash/#!/usr/env bash' How do I make sure that the string #!/bin/bash will ...
0
votes
1answer
898 views

Save result of a grep -c into a shell variable

How can I store the result of grep -c as an integer in a shell variable? This: check=sudo virsh list |egrep -c '\b[0-9]{2}\b' only gives me the number of matches and prints it on screen whereas ...
1
vote
3answers
2k views

Bash: Find and replace text strings

I figured this would be easy, but I'm overlooking something simple: I have a text file called test. It contains, for example, the string Alfred Hitchcock. I want to replace this with Alfred\ ...
0
votes
1answer
357 views

IP Address dotted decimal to /8 or /16 notation using bash,sed or awk?

I have an input file that contains a list of ip addresses and the ip_counts(some parameter that I use internally.)The file looks somewhat like this. 202.124.127.26 2135869 202.124.127.25 2111217 ...
6
votes
3answers
5k views

how to grep and print the next N lines after the hit?

I would like to grep for an occurrence in a text file, then print the following N lines after each occurrence found. Any ideas?