vim sudo
if your working and suddenly you forgot you needed to be root before editing a file. but, you’ve already done lots of changes.. what do you do??
i found out you can gain root privlages after editing a root file
from in vim press esc the type
:w ! sudo tee %
- :w saves
- ! runs a terminal command
- tee % writes what you typed into the file your editing
Caps lock display
- Set the short cuts using compiz or something
- for the command: lock_keys caps
- for the key bindings: Caps_Lock
After that compiz will display a message after you press the Caps lock key. I did not go into details to much but ask questions as neeed.
You can do inline ifs in regex
You can do inline ifs in regex
Syntax:
(?(?=regex)then|else)
Example:
(?(“zach2825”=”/zach/”)”echo ‘zach is in the text’ | echo ‘zach is not in the text’);
Linux sed
In text sometimes you want to remove empty lines.. Well, in linux terminal you can do this easily..
Basic way.
sed ‘/^$/d’ name_of_file -i
the -i says to apply the changes
the first / is there because that is how you commonly start a regex command..
^ is the beginning of the line and $ is for the end of the line so
^$ means there is no text on the line..
/d says to delete the text found..
You can mix this with a find command that i will explain another time but,
you can:
mixed with find
find . -name “*filename.extention*” -exec sed ‘/^$/d’ -i {} \;
after find the . say search from the current working dir and sub dirs
in the -name the “wildcard” char * say to look for everything before and after
then the -exec command is just a terminal command but fot his post i used the sed command from earlier.. and to end the -exec command you have to place a \; at the end..
Sincerely,
Zach2825