Log: Difference between revisions

From genomewiki
Jump to navigationJump to search
No edit summary
 
No edit summary
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
add these two lines to your .bashrc:
I have found a very easy way to keep logfiles of the commands that you executed in your shell to generate a certain annotation file for genome. It was inspired by a [http://www.kuro5hin.org/story/2005/12/28/223217/93 post on kuro5hin] some time ago, Of course, makefiles are better than logfiles, but often you're just hacking around and don't want to bother with escaping those $s and tab-characters.
  alias logadd='history 2 | head -n 1 | cut -d" " -f4- >> log'
  alias logmenu=source ~/usr/bin/scripts/logmenu


When you type '''logadd''' now, the last command you typed will be appended to a file called "log".
The people at UCSC keep their logfiles in an editor: "We write our shell commands in the makeDb/*.txt files first, then cut and paste those commands to the command line.  If they are incorrect, they are corrected in the *.txt file, then cut and paste again to the command line until they work right. The *.txt file is open in an editor until a sequence of operations is completed. --Hiram"
So its a good habit to use '''logadd''' after you have found just the right combination of blat, pslSelect, overlapSelect and faPolyASizes to get your rocket science result to be able to track down those nasty mistakes 6 months later.


Then save the following file under the name '''logmenu''' somewhere:
I prefer my way as it saves me the copy-pasting. The following script allows you to write the last command to a logfile and later run selected commands from your log.


# this scripts needs alias logmenu=source ~/usr/bin/scripts/logmenu
Add these two lines to your .bashrc:
# in your bashrc otherwise the cmds will not find the way into your history
  export HISTIGNORE="logadd:log"
#!/bin/bash
  alias logadd="history -p \!\! >> log.txt"
if [ "$1" == "-h" -o -z $1 ]; then
  alias log="vim log.txt"
    echo logmenu: display the file \"log\" as a menu and let the user choose a command to execute
    echo uses the program \"dialog\"
When you type '''logadd''' now, the last command you typed will be appended to a file called "log.txt".
fi
So its a good habit to use '''logadd''' after you have found just the right combination of blat, pslSelect, overlapSelect and faPolyASizes, to be able to track down those nasty mistakes 6 months later.


echo -n dialog --menu logfile 24 70 18\  > /tmp/menu
[[Category:User Developed Scripts]]
cat log | tr -d \' | gawk "{ ORS=\" \"; print NR, \"\'\" \$0 \"\'\" } " >> /tmp/menu
 
. /tmp/menu 2> /tmp/menuresult
line=`cat /tmp/menuresult`
echo $line
head -n $line log | tail -n 1 > /tmp/line
history -r /tmp/line
. /tmp/line
 
rm -f /tmp/line /tmp/menuresult /tmp/menu

Latest revision as of 17:49, 15 February 2015

I have found a very easy way to keep logfiles of the commands that you executed in your shell to generate a certain annotation file for genome. It was inspired by a post on kuro5hin some time ago, Of course, makefiles are better than logfiles, but often you're just hacking around and don't want to bother with escaping those $s and tab-characters.

The people at UCSC keep their logfiles in an editor: "We write our shell commands in the makeDb/*.txt files first, then cut and paste those commands to the command line. If they are incorrect, they are corrected in the *.txt file, then cut and paste again to the command line until they work right. The *.txt file is open in an editor until a sequence of operations is completed. --Hiram"

I prefer my way as it saves me the copy-pasting. The following script allows you to write the last command to a logfile and later run selected commands from your log.

Add these two lines to your .bashrc:

 export HISTIGNORE="logadd:log"
 alias logadd="history -p \!\! >> log.txt"
 alias log="vim log.txt"

When you type logadd now, the last command you typed will be appended to a file called "log.txt". So its a good habit to use logadd after you have found just the right combination of blat, pslSelect, overlapSelect and faPolyASizes, to be able to track down those nasty mistakes 6 months later.