Thursday, June 8, 2017

Sync up your fork with upstream without creating merge commit

From your fork on the local machine

cd  <fork>
git checkout master
git fetch upstream
git rebase upstream/master
git push -f

This will make your fork match up with what's upstream

 
 

Tuesday, June 6, 2017

Remove CTRL-M characters from a file in UNIX

Recently one of my files started getting these ^M characters at the end of each line. I wanted to remove them quickly and use sed to remove them



sed -i "s/^M//" filename
You need to enter ^M by pressing Ctrl and then pressing V and M in succession



Remove CTRL-M characters from a file in UNIX

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