Using sed and grep to replace the first line of a file

export pattern="pattern"; \
for i in `grep -r -o -n "$pattern" . | grep ":1:=" | sed "s/\(.*\):1:$pattern/\1/g"`; \
do sed -i '1 s/^\(.*\)\(\s{10,}.*\)$/\1/g' "$i"; \
done;

Leave a Reply

Your email address will not be published. Required fields are marked *