The below script will make copy of the file. insert the desired line as the second line.
for LINE in $(cat machines.csv) do ssh root@$LINE "cp /etc/xyz.conf /etc/xyz.conf.old; sed -i '2i nameserver 10.xx.xxx.xxx' /etc/xyz.conf" done
The below script will make copy of the file. insert the desired line as the second line.
for LINE in $(cat machines.csv) do ssh root@$LINE "cp /etc/xyz.conf /etc/xyz.conf.old; sed -i '2i nameserver 10.xx.xxx.xxx' /etc/xyz.conf" done
Remove duplicates and retain the order awk ' !x[$0]++' 1.txt > 2.txt Grep regex to find strings only contains alphabets grep "^[a-zA-Z]*$" alphabets, numbers and + (this is typical for a query string) grep "^[a-zA-Z0-9+]*$"
Grep few characters after match - this case 15 characters after match - for getting the various calls to www.xyz.com grep -E -o "www.xyz.com \"GET \/.{0,15}" httpd2-xyz.com.access-log.1370347200 -o - to show only the match -E - extended regular expression Grep - escape double quote \" -as in above example, before GET
Various calls goes to www.xyz.com from apache logs grep -E -o "www.xyz.com \"GET \/.{0,15}" httpd2-xyz.com.access-log.1370347200 | awk '{ print $3}' | awk '{ if(match($0,"?")) { split($0,a,"?"); print a[1]}}' Grep for lines ending with q= - from the logs which has no query param grep '.*q=$'
Remove empty lines sed '/^$/d' Replace a string sed 's/original/new/' - only first occurence of the line sed 's/original/new/g' - all occurences