Skip to end of metadata
Go to start of metadata

*Search and replace an expression in multiple files in Unix

perl -pi -e 's/findexpression/replaceexpression/g' *.txt
http://www.bigbold.com/snippets/tags/unix

Usage-

perl -pi -e 's/localhost/138.26.144.14/g' ./src/coexpression/*/.java

*grep -R JSci src

finds all the files in the folder src recursively that have the expression JSci in it

Sed Commands

  • sed -e 's/^X//g' nf123-clusterstab-result_cl5.csv

This removed the 'X' character that R always adds to the column names when they start with a number. Several of the NF files (coulmns in a data matrix) started with a number.

VI Commands

  • Append text at the end of multiple lines in VI:

 Current text:

10:100:0.5:0.3:0.05:0.1
10:100:0.5:0.3:0.2:0.1
10:100:0.5:0.7:0.05:0.1

 If I want to append 0.01 at the end of all of the above lines in VI to make:

 10:100:0.5:0.3:0.05:0.1:0.01
10:100:0.5:0.3:0.2:0.1:0.01
10:100:0.5:0.7:0.05:0.1:0.01


Labels
  • None