lunes, 25 de marzo de 2013

Sustituir una cadena en un archivo de texto desde consola de linux

Intente sustituir un carácter (") en  un archivo de texto de 300 MB, pero estaba tardando demasiado además que me estaba consumiendo mas de 1.5GB de RAM y 25% de CPU, lo cancele a los 15 minutos, googleando encontré que puedo hacerlo con esto:

find -name \archivo.txt -exec sed -i "s/\"//g" {} \;

Lo que hace es que en el archivo de texto, busca las comillas y las sustituye por vacio, es decir que las elimina del archivo, en la parte de // puede ir otro caracter por ejemplo comilla simple, que sería de la siguiente manera:

find -name \archivo.txt -exec sed -i "s/\"/'/g" {} \;

 Espero les sirva a mi me ayudo mucho pues el tiempo de respuesta no fue mayor a 1 minuto.

Instalar JDK 7 en ubuntu 12.10

A mi me funciono de la siguiente manera:

This package provides Oracle Java JDK 7 (which includes JRE, the Java browser plugin and JavaFX). However, you can’t only install Oracle JRE – the PPA only provides the full Oracle JDK7 package.
1. To add our PPA and install the latest Oracle Java (JDK) 7 in Ubuntu, use the commands below:
#sudo add-apt-repository ppa:webupd8team/java
#sudo apt-get update && sudo apt-get install oracle-jdk7-installer
2. After the installation you have enable the jdk:
#update-alternatives –display java
3. Check if Ubuntu uses Java JDK 7
#java -version
If all went right the answer should be something like this:
java version “1.7.0_07″
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) Server VM (build 23.3-b01, mixed mode)
4. Check what compiler is used:
#javac -version
The correct answer should be like this:
javac 1.7.0_07
5. Adding JAVA_HOME to environment
Edit /etc/environment and add JAVA_HOME=/usr/lib/jvm/java-7-oracle to the end of the file.
First open a Terminal (Applications → Accessories → Terminal), then enter:
#sudo gedit /etc/environment
Append to the end of the file:
JAVA_HOME=/usr/lib/jvm/java-7-oracle
6. Removing Oracle JDK 7
If you don’t want to use Oracle Java (JDK) 7 anymore and want to go back to OpenJDK, all you have to do is remove the Oracle JDK7 Installer and the previous Java (OpenJDK, etc.) version will be used:
#sudo apt-get remove oracle-jdk7-installer


Lo tomé de: http://www.blogs.digitalworlds.net/softwarenotes/?p=41