Recent Notes

Displaying keyword search results 1 - 10
Created by voodoo on March 24, 2013 13:44:47    Last update: March 29, 2013 13:08:31
Use getpwnam group of functions. Example code: #include <sys/types.h> #include <pwd.h> #inc... For gid, use getgrnam
Created by voodoo on September 17, 2012 15:02:15    Last update: September 17, 2012 15:02:15
Start gdb with the executable and coredump: $ gdb <path to executable> core While in the debugger, use the following commands: (gdb) where ("shows a summary of the stack") ... Example debug session from Debugging Under Unix: gdb Tutorial : Use backtrace (or bt ) to see the callstack: (gdb) backtrace #0 Node<int>::next (this=0x0) ... Inspect the value of item_to_remove at address 0xffbef014 (the value is 1): (gdb) x 0xffbef014 0xffbef014: 0x00000001 (g... Note: The program must be compiled with the debug switch -g in order to see the source code. More resources: Linux software debugging with GDB Debugging with gdb
Created by voodoo on August 15, 2012 11:23:44    Last update: August 15, 2012 11:23:44
By default Linux pipe output is buffered. For example, you can't see the most recent stdout on screen with tee : $ ./mycommand | tee /tmp/mycommand.log Here are two ways to make the pipe unbuffered. Method 1: use the unbuffer command from expect $ sudo apt-get install expect-dev $ unbuffer ./... Method 2: use stdbuf # Make output line buffered: $ stdbuf -oL ./myc...
Created by voodoo on August 15, 2012 09:07:41    Last update: August 15, 2012 09:07:41
$ var='variable to be truncated' $ echo ${var#v...
Created by Dr. Xi on August 13, 2012 14:54:44    Last update: August 13, 2012 14:54:44
According to wikipedia , only two characters are invalid in a file name: In Unix-like file systems the null character, as that is the end-of-string indicator and the path separator / are prohibited.
Created by Dr. Xi on February 24, 2012 13:01:01    Last update: February 24, 2012 13:01:01
To zip all files under js and css , but exclude the svn files: $ zip -r css-js.zip css js -x '*.svn*'
Created by voodoo on February 16, 2012 14:56:44    Last update: February 16, 2012 15:52:56
Shell functions are declared using this syntax: [ function ] name () compound-command [ redirectio... Example: function ll { ls -alF $* } Example 2: ll() { ls -alF $* } Shell functions can be exported to subshells with the -f switch: $ export -f ll However , I had problems logging in Ubuntu 11.10 after I added this to .profile : export -f ll
Created by voodoo on January 03, 2012 08:41:21    Last update: February 16, 2012 15:50:06
This is the command to print all regular files in the src folder but excluding all files within the .svn folders: $ find src -name .svn -prune -o -type f -print where -o is the or operator. Define a shortcut: ff () { find $1 -name .svn -prune -o -...
Created by voodoo on February 16, 2012 14:57:35    Last update: February 16, 2012 14:57:35
You can use either declare or typeset to list function definitions : To list all function names: declare -F To display a function definition: $ declare -f quote quote () { echo ... If you see a lot of functions with names starting with the underscore ( _ ) and wonder where they come from, they are created by the scripts in /etc/bash_completion.d/ .
Created by voodoo on February 16, 2012 13:35:38    Last update: February 16, 2012 13:35:57
The C shell allows you to define aliases with arguments: \!^ passes the first argument, \!* passes all arguments. Examples from http://unixhelp.ed.ac.uk : alias print 'lpr \!^ -Pps5' alias print 'lp... In ksh or bash you cannot define alias with arguments. Use function instead.
Previous  1 2 3 4 5 6 7 8 9 10 Next