Notes by woolf

Displaying keyword search results 1 - 7
Created by woolf on September 30, 2011 13:58:02    Last update: September 30, 2011 13:58:14
Use IO redirection to swap stdout and stderr : $ prog 3>&1 >&2 2>&3 3>&-
Created by woolf on September 08, 2011 11:19:52    Last update: September 08, 2011 11:19:52
To check a command exists on PATH: Use the return code of which : which some_command &>/dev/null [ $? -eq 0 ] || ... For bash, use type -P : type -P some_command &>/dev/null && echo "ome_comm... or check_path() { if ! type -P $1 &> /dev/...
Created by woolf on July 05, 2011 15:38:52    Last update: July 05, 2011 15:39:55
By default VirtualBox enables one network adapter ("Adapter 1") with NAT. Connection from the guest OS to the outside world works natually when the guest network adapter is assigned an IP address by the VirtualBox DHCP server. Use VBoxManage to see a list of DHCP servers: $ VBoxManage list dhcpservers NetworkName: H... The guest IP address is not visible from the outside world. If you need to access a server on the guest OS, you need to set up port forwarding in VirtualBox settings: Settings -> Network -> Adapter 1 -> Advanced -> Port Forwarding . Beware that on Linux/Unix, port forwarding may not work if you bind to a privileged port (port number < 1024) but you are not root. Bridged networking can be...
Created by woolf on May 20, 2011 14:00:35    Last update: May 20, 2011 14:01:36
To remove new line characters from a file: with tr : tr -d '\n' < the-file.txt or cat the-file.txt | tr -d '\n' with sed : sed ':a;N;$!ba;s/\n//g' the-file.txt or cat the-file.txt | sed ':a;N;$!ba;s/\n//g' The sed version is a bunch of commands to manipulate the register etc. Regex replace " s/\n//g " does not work because sed regex works on a single line. More tips from this Linux blog: http://linux.dsplabs.com.au/rmnl-remove-new-line-characters-tr-awk-perl-sed-c-cpp-bash-python-xargs-ghc-ghci-haskell-sam-ssam-p65/
Created by woolf on May 20, 2011 13:46:04    Last update: May 20, 2011 13:46:04
The Unix utility can convert a binary stream to hex and reverse it. The -p (or -ps ) switch means "plain", or "postscript" mode. $ cat >test.txt Line one Line two Line th...
Created by woolf on May 15, 2011 15:11:42    Last update: May 15, 2011 15:11:57
On windows, display IPv4 routing table: route -4 print On Linux: $ route Kernel IP routing table Destination ... This works for both Linux and Windows (" -r ": display routing table, " -n ": display address and port numbers in numerical form): netstat -rn
Created by woolf on April 12, 2011 09:20:08    Last update: April 12, 2011 09:20:08
First try (this lists files by directory, including directories themselves): ls -R -lrt Second try: find . -type f | xargs ls -lrt