A collection of things I find useful (but can never remember).
Table of Contents
Unix Commands
How to find the size of a directory in Linux
>> du -sh
Comparing the differences between two directories of files that are almost the same.
>> diff -bur folder1/ folder2/
Finding a particular file in a folder in linux
This will look in the current folder (and sub-directories) for that string in a name of a file.
>> find . -name '*default_setup.use'
How to find out my Linux distribution name and version
>> cat /etc/*-release
Use of –parents flag in mkdir and cp
Useful if you want to keep the folder hierarchy when you’re copying. (For instance, if you have two files called ‘temp_calib0.inc’ and they’re in different folders. If you copy them over to one location, you need to either rename or put them in different folders).
>> xargs -a copy_files.txt cp --parents -t /net/10.xx.xx.xx/XXX/XXX/XXX/copied_files/
Watch – watching the output of certain commands
Watching paint dry is so twentieth century..
An exampl
>> watch bhappy
How can I make grep print the lines below and above each matching line?
>> grep -A 1 -B 1 -nR 'yourString*' .
This will allow you to see the context in which your grep hit. So the lines before and after it.
Emacs
Deleting the first ‘x’ characters from every line in a region with Emacs – Stack Overflow
You use your mark tool (‘C-Spc’) to highlight a box area and then use the command ‘C-x r k’ to remove this square/rectangle.
Don’t worry about the mark tool highlighting the edges of lines in between, they won’t be clipped.
Handy way to append a flag to the end of a line.
Command: M-< M-x replace-regexp RET $ RET a RET
This will place an ‘a’ at the end of all lines. The $ matches the end-of-line character.
Also one of the other answers shows how to use key-macros so could be handy later.
loading – Reload configurations without restarting Emacs – Stack Overflow
A quick way to reload your .emacs after making changes, to save a restart.
M-x eval-buffer
Finding location of .emacs file.
C-h v 'user-init-file'
Link: https://stackoverflow.com/questions/864892/how-do-i-find-which-emacs-file-has-been-loaded