Monday, May 22, 2017

Change a string in a file based on line number

I came across this situation where I needed to change the timeout of a certain command alone in a script temporarily and automatically. I came across a solution using sed

sed -i "24s/timeoutValue1/timeValue2/" fileName

Ref:
Replace String Based on Line Number

Thursday, May 18, 2017

Changing the size of wallpaper in RHEL 7

I was trying to change my wallpaper and put up the new image. But it was zoomed in and I couldn't figure out how to change from zoomed to scaled.

On googling, I found the link below. You need dconf-editor to do this. Open up dconf-editor and go to

org -> gnome -> desktop -> background

and there you can change from zoomed to scaled.


Ref:
Cant change size of wallpaper (stock or from home/pictures) 13.10 using gnome3


Thursday, May 11, 2017

How to search for multiple strings in a file using grep

I wanted to search for both ERROR and FAIL in a file using grep.

Came across this:

grep -E "ERROR|FAIL" filename

Or
grep "ERROR\|FAIL" filename

For searching a file for lines not containing a string

grep -v "PASS" filename 

Reference:
Grep OR, AND and NOT operators