grep
oneliner: copy file that has searched phrase
Because my server history sometimes changes, I have to write down my favourite oneliner - which copy every file from some which contains searched phrase/word.
for i in `egrep -li ’searched phrase’ *.eml`; do cp $i found/; done
if you just want to see those files, change cp to echo, like this
for i in `egrep -li ’searched phrase’ *.eml`; do echo $i; done
but this one - is made just by:
egrep -li ’searched phrase’ *.eml
![]()
remove all hashes (#) from config files
Nice tip - how to remove all hashes from config (or another files).
I know just two methods, but this one I find best:
grep -v ‘^#’ file > file.new
second one (this one overwrite the main file):
sed -e ‘/^#/d’ -i file
you can even use vim, but it will remove all lines with #, not starting from hash.
:g/pattern/d