Code Monkey home page Code Monkey logo

bash_cheatsheet's Introduction

Bash_cheatsheet

Useful tricks I always needs, I'm always searching and finding them hours after...

Bash shell in OSX:

Add newlines after a pattern

sed 's/XXX/XXX\'$'\n/g' file > file_02

ex:

sed 's/Control_3_30c/Control_3_30c\'$'\n/g' file > file_02

Add a line a the top of a file, with tabulation within:

sed $'1s/^/ZZZa\tYYYb\tXXX/' file > file_02

ex:

sed $'1s/^/Acclimation_1_31_5a\tAcclimation_1_31_5b\tAcclimation_1_31_5c\tAcclimation_3_30a\tAcclimation_3_30b\tAcclimation_3_30c\tControl_1_30a\tControl_1_30b\tControl_1_30c\tControl_3_30a\tControl_3_30b\tControl_3_30c/' file > file_02

Obtain count, min and max for each unique entry, useful for obtainning genes lengths from only an exon database:

awk '{
  count[$1]++
  min[$1]=(!($1 in min) || $2<min[$1]) ? $2 : min[$1]
  max[$1]=(!($1 in max) || $3>max[$1]) ? $3 : max[$1]
}
END {
  print "Name","Count","Minimum","Maximum"
  print "----","-----","-------","-------"
  for(i in count) print i,count[i],min[i],max[i]
}' input_file > output_file | column -t

Known how many same genes are into same cluster (here, if only two replicate)

awk 'seen[$0]++ && seen[$0] == 2' 

Other

awk '{print $1}'

bash_cheatsheet's People

Contributors

plstenger avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.