grep result for if clause (bash)
I want part of my bash script to only be executable if there's a certain grep match.
Here's what I want in the if clause: Code:
install -m644 -D ${srcdir}/${pkgname}.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset || return 1 Here's the grep line: Code:
grep -F CONFIG_BLK_DEV_INITRD=y /path/to/file I want it to look like this, but I don't know how to state it: Code:
if grep -F CONFIG_BLK_DEV_INITRD=y /path/to/file |
Quote:
if there's a usable return code you can check the return code in $ in if. http://www.technologyquestions.com/t...sh-script.html this address gives some examples. |
if [[ $(grep -F CONFIG_BLK_DEV_INITRD=y /path/to/file 2> /dev/null) ]] ; then
I haven't checked for sure, but you meay need to esacpe the '=': if [[ $(grep -F 'CONFIG_BLK_DEV_INITRD\=y' /path/to/file 2> /dev/null) ]] ; then |
Quote:
Thank you. |
All times are GMT -5. The time now is 07:52 AM. |