vi -N test.txt
jueves, 30 de abril de 2020
vim in nocompatible mode
If the arrow keys make a mess (like typing A, B, C or D) in insert mode, try the nocompatible mode (-N) (makes vim work "Not fully Vi compatible"):
vi -N test.txt
vi -N test.txt
sábado, 7 de diciembre de 2019
bash autocomplete
COMPLETE_OPTIONS="host1 host2"
function _ssh_complete {
local cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${COMPLETE_OPTIONS}" -- ${cur}) )
}
complete -F _ssh_complete ssh
function _ssh_complete {
local cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${COMPLETE_OPTIONS}" -- ${cur}) )
}
complete -F _ssh_complete ssh
sábado, 17 de enero de 2015
ipfilter testing
add another port to sshd:
$ grep Port /etc/ssh/sshd_config
Port 22
Port 44444
test it works:
$ telnet 127.0.0.1 44444
block that port:
$ cat /etc/ipf/ipf.conf
set intercept_loopback true;
pass in all
pass out all
block in from any to any port = 44444
#pass in from 127.0.0.1 to any port = 44444
test it's blocked
$ telnet 127.0.0.1 44444
just in case we screw:
$ sudo crontab -l | tail -n1
* * * * * /usr/sbin/svcadm disable network/ipfilter
$ grep Port /etc/ssh/sshd_config
Port 22
Port 44444
test it works:
$ telnet 127.0.0.1 44444
block that port:
$ cat /etc/ipf/ipf.conf
set intercept_loopback true;
pass in all
pass out all
block in from any to any port = 44444
#pass in from 127.0.0.1 to any port = 44444
test it's blocked
$ telnet 127.0.0.1 44444
just in case we screw:
$ sudo crontab -l | tail -n1
* * * * * /usr/sbin/svcadm disable network/ipfilter
martes, 11 de noviembre de 2014
newline in sed or echo on Mac
$ echo hello | sed 's/hello/hello\'$'\nbye/'
hello
bye
$ echo hello | sed 's/hello/hello\'$'\n''bye1\'$'\nbye2/'
hello
bye1
bye2
$ sed -i '' 's/hello/hello\'$'\nbye/g' somefile.txt
hello
bye
$ echo hello | sed 's/hello/hello\'$'\n''bye1\'$'\nbye2/'
hello
bye1
bye2
$ sed -i '' 's/hello/hello\'$'\nbye/g' somefile.txt
martes, 10 de junio de 2014
Fast copy of directories using nc
receiving end (using port 10000):
nc -l 10000 | tar x
sending end:
cd parent_dir
tar cf - *hello* | nc receiving_hostname 10000
nc -l 10000 | tar x
sending end:
cd parent_dir
tar cf - *hello* | nc receiving_hostname 10000
miércoles, 18 de diciembre de 2013
How do I add text to the beginning of a file
sed -i '1iline text at the beginning' hello.txt
http://superuser.com/questions/246837/how-do-i-add-text-to-the-beginning-of-a-file-in-bash
http://superuser.com/questions/246837/how-do-i-add-text-to-the-beginning-of-a-file-in-bash
martes, 26 de noviembre de 2013
Test if string is a number in Ruby
def is_number?(object)
true if Float(object) rescue false
end
(http://stackoverflow.com/questions/5661466/test-if-string-is-a-number-in-ruby-on-rails)
Suscribirse a:
Entradas (Atom)